Sisyphus sequence: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (Corrected spelling mistake.)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(One intermediate revision by one other user not shown)
Line 307:
77,534,485,877th member is 36 and highest prime needed is 677,121,348,413
</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight lang="easylang">
func isprim num .
if num mod 2 = 0 and num > 2
return 0
.
i = 3
while i <= sqrt num
if num mod i = 0
return 0
.
i += 2
.
return 1
.
prim = 1
proc nextprim . .
repeat
prim += 1
until isprim prim = 1
.
.
numfmt 0 4
n = 1
write n
for i = 2 to 100
if n mod 2 <> 0
nextprim
n += prim
else
n /= 2
.
write n
if i mod 10 = 0
print ""
.
.
</syntaxhighlight>
 
=={{header|J}}==
Line 1,480 ⟶ 1,519:
 
Extreme stretch not attempted and out of reasonable reach for Wren-CLI.
<syntaxhighlight lang="ecmascriptwren">import "./math" for Int, Nums
import "./fmt" for Fmt
 
Line 1,558 ⟶ 1,597:
 
The following script manages to find the first occurrence of the number 36 in the sequence in about 2 hours 54 minutes which (relative to Phix) is much quicker than one would normally expect. This is probably due to the heavy lifting (i.e. the prime generation) being done here in both cases by C++ though this will tempered by the need to convert unsigned 64-bit integers to doubles (Wren's only numeric type) for each prime generated.
<syntaxhighlight lang="ecmascriptwren">import "./psieve" for Primes
import "./fmt" for Fmt
 
9,476

edits