Untouchable numbers: Difference between revisions
m
→{{header|Phix}}: to 1 million
(→{{header|Go}}: Reverted to a limit of 100,000 as 1 million figure was miles out!) |
m (→{{header|Phix}}: to 1 million) |
||
Line 276:
=={{header|Phix}}==
<lang Phix>constant limz = {1,1,8,9,18,64} -- found by experiment
atom t0 = time(), t1 = t0+1
bool tell = n>0
n = abs(n)
Line 288 ⟶ 290:
end for
sums[5] = 0
integer m = floor(log10(n))
-- for j=2 to 2*n do▼
integer lim = limz[m]*n
integer y = sum(factors(j,-1))
if y<=n then
sums[y] = 1
end if
if time()>t1 then
progress("j:%,d/%,d (%3.2f%%)\r",{j,lim,(j/lim)*100})
t1 = time()+1
end if
end for
progress("")
if tell then
printf(1,"The list of all untouchable numbers <= %d:\n",{n})
Line 319 ⟶ 327:
printf(1,"\n")
end if
t0 = time()-t0
printf(1,"%,20d untouchable numbers were found <= %,d\n",{cnt,n})▼
string t = iff(t0>1?elapsed(t0,fmt:=" (%s)"),"")
▲ printf(1,"%,20d untouchable numbers were found <= %,d%s\n",{cnt,n,t})
for p=1 to tens do
untouchable(-power(10,p))
Line 325 ⟶ 335:
end procedure
untouchable(2000, 10,
{{out}}
<pre>
Line 352 ⟶ 362:
196 untouchable numbers were found <= 2,000
2 untouchable numbers were found <= 10
89 untouchable numbers were found <= 1,000
1,212 untouchable numbers were found <= 10,000
13,863 untouchable numbers were found <= 100,000 (12.4s)
150,232 untouchable numbers were found <= 1,000,000 (33 minutes and 55s)
</pre>
for comparison, on the same box, the Julia entry took 58 minutes and 40s.
=={{header|REXX}}==
|