Rare numbers: Difference between revisions
Content added Content deleted
(Added Quackery.) |
|||
Line 4,038: | Line 4,038: | ||
15 10:42 |
15 10:42 |
||
</pre> |
</pre> |
||
=={{header|Quackery}}== |
|||
Naive version. |
|||
Timings for Quackery running on PyPy3 on one core of a 3 GHz 6-Core Intel Core i5 Mac mini at 100%. |
|||
First result; less than a second. Second result; less than five minutes (possibly a lot less - I went to make a cup of tea), third result; more than twelve and less than fifteen hours. At this point I estimated from other timings on this page that getting the fourth and fifth results would take about a week and killed the process. :-( |
|||
On the other hand; code development time, less than five minutes. :-) |
|||
<lang Quackery>[ dup 1 |
|||
[ 2dup > while |
|||
+ 1 >> |
|||
2dup / again ] |
|||
drop nip ] is sqrt ( n --> n ) |
|||
[ dup sqrt 2 ** = not ] is !square ( n --> b ) |
|||
[ number$ reverse |
|||
$->n drop ] is revnumber ( n --> n ) |
|||
[ 0 swap |
|||
[ base share /mod |
|||
rot + swap |
|||
dup 0 = until ] |
|||
drop ] is digitalroot ( n --> n ) |
|||
[ true swap |
|||
dup revnumber |
|||
2dup > not iff |
|||
[ 2drop not ] done |
|||
2dup + !square iff |
|||
[ 2drop not ] done |
|||
2dup - !square iff |
|||
[ 2drop not ] done |
|||
2drop ] is rare ( n --> b ) |
|||
[ 0 |
|||
[ 1+ dup rare if |
|||
[ dup echo cr |
|||
dip [ 1 - ] ] |
|||
over 0 = until ] |
|||
2drop ] is echorarenums ( n --> b ) |
|||
5 echorarenums</lang> |
|||
{{Out}} |
|||
<pre>5 |
|||
621770 |
|||
281089082</pre> |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |