Week 33 of 145 ยท TAOCP Vol 1: Fundamental Algorithms

TAOCP 1.2.4 Integer Functions and Elementary Number Theory

2 tasks, 5 steps. Open a task's steps to see exactly what to do; each guide has the detail.

Sign up or sign in to tick these off and give this week a due date.

By the end of this week you can

  • Compute floors, ceilings and x mod y with negative arguments.
  • Explain why Knuth's mod differs from C's % operator on negatives.
  • Use congruences and Fermat's theorem on small examples.

Week 33 ยท Self-check

Three quick questions

Ungraded, and it never holds anything up. Pick an answer to see why.

  1. With Knuth's definition x mod y = x - y floor(x/y), what is -7 mod 3?
  2. What is floor(-2.5)?
  3. By Fermat's theorem, what is 2^7 mod 7?

Nothing is saved while signed out.

Discussion

0 posts

Stuck on week 33, or finished early? Say what you tried and what happened. Hints over answers: full solutions go in a spoiler.

No posts yet. Ask a question or share a tip.

Sign in to postAnyone can read. Posting needs an account with a confirmed email.

Spot a mistake? Report it