-1

Given $10<a<m<10a$, is it possible to calculate $10a \pmod{m}$ without calculating $10a$ ($a$ and $m$ are very big numbers)?

Note that the formula $$ab \pmod{m}=((a \pmod{m}) \cdot (b \pmod{m}) \pmod{m}$$ is of no use here, since it will get us back to $10a \pmod{m}$

Edit: Thanks for fixing my question. It's clear now.

Edit2: I need to avoid overflow (in programming) when $10a$ is too big to fit in an integer.

Chezi
  • 17
  • 1
    $a^{10}$, not a*10, please. Or $10a$, if that is what you really mean--it is not clear. By not making an effort to make your post clear and easier/more pleasant to read, you are showing disrespect to the MSE Community. It also goes against the MSE Guidelines as well. -1 – Mike May 16 '24 at 19:56
  • What does the asterisk mean? If it mean multiplication this question really seems very very easy. If it means something else.... well, I can't guess what it is. – fleablood May 16 '24 at 19:57
  • What sort of answer do you want or expect? Just add $a$ to itself and take the remainder. It'll take you at most $10$ iterations. If $a$ and $m$ are too large to do that then... why do you expect there to be any other reasonable answer. And what's wrong with simply saying you want $10a$. Why is the $v \equiv 10a$ where $v < m$ and more valuable? – fleablood May 16 '24 at 20:04
  • Excuse me for not being a math expert. Oh wait, this is why I asked for help! – Chezi May 16 '24 at 20:26
  • In the linked dupe see "repeated doubling" (Peasant multiplication), i.e. the additive analog of repeated squaring. – Bill Dubuque May 16 '24 at 21:09

1 Answers1

1

Not sure of your use case, but there's a way to do it modeled on exponentiation by squaring - you could call it "multiplication by doubling":

  • Compute $b = 2a \pmod{m}$
  • Compute $c = 2b \pmod{m}$ - that will be $4a \pmod{m}$
  • Compute $d = 2c \pmod{m}$ - that will be $8a \pmod{m}$
  • Compute $e = b+d \pmod{m}$ - that will be $10a \pmod{m}$

However I'm having trouble thinking of a situation where computing $10a$ would be infeasible but computing $2a$ would be no big deal.

Michael Lugo
  • 24,422
  • Many computer operating systems find multiplying an integer by 2 easier than multiplying the same integer by 10. – Lieven May 16 '24 at 19:58
  • I think the last step should be $e=b+d,$ not $e=bd.$ – Lieven May 16 '24 at 19:59
  • @Lieven: yes, you're right, I forgot that I was doing multiplication by doubling and not exponentiation by squaring. – Michael Lugo May 16 '24 at 20:00
  • Please strive not to post more (dupe) answers to dupes of FAQs. This is enforced site policy, see here. It's best for site health to delete this answer (which also minimizes community time wasted on dupe processing.) – Bill Dubuque May 16 '24 at 20:10