Ultra useful primes: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Promote. multiple implementations, no questions) |
Drkameleon (talk | contribs) (Added Arturo implementation) |
||
Line 47: | Line 47: | ||
1 3 5 15 5 59 159 189 569 105 |
1 3 5 15 5 59 159 189 569 105 |
||
</pre> |
</pre> |
||
=={{header|Arturo}}== |
|||
<lang rebol>ultraUseful: function [n][ |
|||
k: 1 |
|||
p: (2^2^n) - k |
|||
while ø [ |
|||
if prime? p -> return k |
|||
p: p-2 |
|||
k: k+2 |
|||
] |
|||
] |
|||
print [pad "n" 3 "|" pad.right "k" 4] |
|||
print repeat "-" 10 |
|||
loop 1..10 'x [ |
|||
print [(pad to :string x 3) "|" (pad.right to :string ultraUseful x 4)] |
|||
]</lang> |
|||
{{out}} |
|||
<pre> n | k |
|||
---------- |
|||
1 | 1 |
|||
2 | 3 |
|||
3 | 5 |
|||
4 | 15 |
|||
5 | 5 |
|||
6 | 59 |
|||
7 | 159 |
|||
8 | 189 |
|||
9 | 569 |
|||
10 | 105</pre> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |