Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #digits
ADD COMMENT
Topic
Name
4+1 =