Iccanobif primes: Difference between revisions
→J: fix wrong result
(Added Quackery.) |
(→J: fix wrong result) |
||
Line 537:
=={{header|J}}==
Implementation:
2 3 5 31 43 773 7951 64901 52057 393121 56577108676171</syntaxhighlight>
▲<syntaxhighlight lang=J> (#~ 1 p:])|.&.|:"0 (, _2 +/@{. ])^:70]1
In other words
▲In other words, 70 numbers from the fibonacci sequence, reverse their digits, and keep those which are prime.
Stretch:
▲<syntaxhighlight lang="J"> #@":@> 10}. (#~ 1&p:)|.&.(10&#.inv)"0 (, _2 +/@{. ])^:20000]1x
14 21 37 40 80 104 137 330 406 409 503 888 1020 1122 1911 1947 2283 3727</syntaxhighlight>
For the stretch goal we use extended precision integers instead of the usual fixed width representation, and reverse the digits numerically rather than relying on the character representation of the numbers (though it's simplest to rely on the character representation for counting the digits of the resulting primes).
|