Ulam numbers: Difference between revisions

m (→‎{{header|Phix}}: forgot to define t and update the reduced elapsed time)
Line 386:
The above algorithm can also yield "The 100,000th Ulam number is 1,351,223" in 1 minute and 40s, for me.
<small>(I fully expect translations of this better algorithm to run even faster, btw)</small>
 
 
=={{header|Python}}==
{{trans|XPL0}}
<lang python>
t0 = time.time()
for p in range(5):
n = 10**p
print(f"The {n}{'th' if n!=1 else 'st'} Ulam number is {ulam(n)}\n")
 
print("\nElapsed time:", time.time() - t0)
</lang>
 
{{out}}
<pre>The 1st Ulam number is 1
 
The 10th Ulam number is 18
 
The 100th Ulam number is 690
 
The 1_000th Ulam number is 12_294
 
The 10_000th Ulam number is 132_788
 
 
(Elapsed time: 11.470759391784668 seconds)</pre>
 
=={{header|Raku}}==
Anonymous user