0

Example: Suppose I have a number a with 100 decimal digits, b with 200 decimal digits, and m with 10 decimal digits.

Would the speed of the computation a mod m vary greatly from b mod m because of the size of a vs b?

Raphael
  • 72,336
  • 29
  • 179
  • 389

2 Answers2

2

Yes. You are doing long division. Whatever method you use, you will lose you a roughly constant number of digits per step, so there will be twice as many (well, about $\frac{190}{90}$ times as many) steps for $b$ as for $a$.

Martin Kochanski
  • 1,064
  • 6
  • 8
0

In general it does, however, for certain special cases it will not.

A simple example is when $m$ is a power of 2. Then, the reminder is exactly the last $\log m$ bits of $n$, regardless of the size of $n$.

Ran G.
  • 20,684
  • 3
  • 60
  • 115