Dream_Coder10's blog

By Dream_Coder10, history, 4 weeks ago, In English

why moduler multiplicative inverse is not working under modulo 1000000007 by fermats littile theorem ? let n=11 & k=3 ; n/k should be equal to 3. but its giving me 666666675. same thing goes for n=10 & k=4;

problem:

https://paste.ubuntu.com/p/vgTZcHQ8Rv/

my code:

https://paste.ubuntu.com/p/s2m5q4JtMs/

 
 
 
 
  • Vote: I like it
  • -26
  • Vote: I do not like it

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Dream_Coder10 (previous revision, new revision, compare).

»
4 weeks ago, # |
  Vote: I like it +5 Vote: I do not like it

Modular multiplicative inverse of $$$3$$$ under modulo $$$(10^9 + 7)$$$ is $$$333333336$$$ because $$$3 * 333333336 = 1 (mod (10^9 + 7))$$$

$$$11 * 333333336 = 666666675 (mod (10^9 + 7))$$$

It is correct.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    ok..can u tell me about my approach correct or wrong?

    problem link is given below:

    https://paste.ubuntu.com/p/vgTZcHQ8Rv/

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      You are giving the problem in a very weird format.

      I don't see how inverses can be used here. You should evenly divide the stick and use just (fast) modular exponentiation.