Frobenius numbers: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
(Added Quackery.) |
||
Line 1,320: | Line 1,320: | ||
</pre> |
</pre> |
||
=={{header|Quackery}}== |
|||
<code>eratosthenes</code> and <code>isprime</code> are defined at [[Sieve of Eratosthenes#Quackery]]. |
|||
In this solution the primes and Frobenius numbers are zero indexed rather than one indexed as per the task. It simplifies the code a smidgeon, as Quackery nests are zero indexed. |
|||
<syntaxhighlight lang="Quackery"> 200 eratosthenes |
|||
[ [ [] 200 times |
|||
[ i^ isprime if |
|||
[ i^ join ] ] ] |
|||
constant |
|||
swap peek ] is prime ( n --> n ) |
|||
[ dup prime |
|||
swap 1+ prime |
|||
2dup * rot - swap - ] is frobenius ( n --> n ) |
|||
[] 0 |
|||
[ tuck frobenius dup |
|||
10000 < while |
|||
join swap |
|||
1+ again ] |
|||
drop nip echo </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|Raku}}== |
=={{header|Raku}}== |