You are not logged in. Please login at www.codechef.com to post your questions!

×

inverse modulo

can someone explain why this code works and theory behind it

inv[0]=inv[1]=1;
    for(i=2;i<=max;i++)
            inv[i] = mod - (((long long)mod/i)*inv[mod%i])%mod;
This question is marked "community wiki".

asked 17 Jul '13, 12:03

ac_c0der's gravatar image

2★ac_c0der
72448
accept rate: 0%


link

answered 17 Jul '13, 13:03

kingarthurie's gravatar image

4★kingarthurie
70347
accept rate: 16%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×333
×52

question asked: 17 Jul '13, 12:03

question was seen: 4,699 times

last updated: 17 Jul '13, 13:03