24 lines
722 B
Text
24 lines
722 B
Text
with javascript_semantics
|
|
atom t0 = time()
|
|
|
|
procedure nth_cyclops(atom n)
|
|
string cyclops = "0"
|
|
if n>1 then
|
|
atom hlen = 1, hlen2 = 1, w = n-1, digits = 0
|
|
while w>=hlen2 do
|
|
w -= hlen2
|
|
hlen *= 9
|
|
hlen2 = power(hlen,2)
|
|
digits += 1
|
|
end while
|
|
string hf = sprintf("%%0%da/%%0%da",digits)
|
|
cyclops = sq_add(1,sprintf(hf,{{9,floor(w/hlen)},{9,round(remainder(w,hlen))}}))
|
|
end if
|
|
string fmt = "The %,d%s cyclops number is %s%s\n",
|
|
e = elapsed(time()-t0,0.1," (%s)")
|
|
printf(1,fmt,{n,ord(n),cyclops,e})
|
|
end procedure
|
|
for n=0 to iff(machine_bits()=32?15:18) do
|
|
nth_cyclops(power(10,n))
|
|
end for
|
|
?elapsed(time()-t0)
|