Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

inverse modulo

$
0
0

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;

Viewing all articles
Browse latest Browse all 39796

Trending Articles