Answers for "first k digits of n*n"

0

first k digits of n*n

factor = n mod 10^k
result = 1
while (n != 0) 
    if (n is odd) then result = (result * factor) mod 10^k
    factor = (factor * factor) mod 10^k
    n >>= 1
Posted by: Guest on August-21-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language