Frobenius numbers: Difference between revisions

Added Easylang
No edit summary
(Added Easylang)
 
(3 intermediate revisions by 2 users not shown)
Line 763:
</pre>
 
 
=={{header|EasyLang}}==
<syntaxhighlight>
fastfunc isprim num .
i = 2
while i <= sqrt num
if num mod i = 0
return 0
.
i += 1
.
return 1
.
fastfunc nextprim prim .
repeat
prim += 1
until isprim prim = 1
.
return prim
.
prim = 2
repeat
prim0 = prim
prim = nextprim prim
x = prim0 * prim - prim0 - prim
until x >= 10000
write x & " "
.
</syntaxhighlight>
{{out}}
<pre>
1 7 23 59 119 191 287 395 615 839 1079 1439 1679 1931 2391 3015 3479 3959 4619 5039 5615 6395 7215 8447 9599
</pre>
 
=={{header|Factor}}==
Line 1,589 ⟶ 1,622:
Found 25 Frobenius numbers
done...</pre>
 
=={{header|RPL}}==
« → max
« { } 2 OVER
'''DO'''
ROT SWAP + SWAP
DUP NEXTPRIME DUP2 * OVER - ROT -
'''UNTIL''' DUP max ≥ '''END'''
DROP2
» » ‘<span style="color:blue>FROB</span>’ STO
 
10000 <span style="color:blue>FROB</span>
{{out}}
<pre>
1: { 1 7 23 59 119 191 287 395 615 839 1079 1439 1679 1931 2391 3015 3479 3959 4619 5039 5615 6395 7215 8447 9599 }
</pre>
 
=={{header|Ruby}}==
Line 1,701 ⟶ 1,750:
=={{header|Wren}}==
{{libheader|Wren-math}}
{{libheader|Wren-seq}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./math" for Int
import "./seqfmt" for LstFmt
import "/fmt" for Fmt
 
var primes = Int.primeSieve(101)
Line 1,715 ⟶ 1,762:
}
System.print("Frobenius numbers under 10,000:")
Fmt.tprint("$,5d", frobenius, 9)
for (chunk in Lst.chunks(frobenius, 9)) Fmt.print("$,5d", chunk)
System.print("\n%(frobenius.count) such numbers found.")</syntaxhighlight>
 
1,969

edits