Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how accelerate this simple program

Hello everybody. Here is my question We seek integers of which the decimal part of their square root begin by 2017. Sample: sqrt(10858) = 104.201727.... Here is my program:

for n in range (1, 10^5):
    if int(  N(sqrt(n)).frac() * 10000 )  == 2017:
        cpt += 1

the problem is it takes too much time. For the bound 10^5 it takes about 55 sec on my iMac, for 10^6 it takes 620 sec, for 10^7 it takes almost 6000 sec ... The question is to obtain the result for the bound 10^10 !