Jump to content

Truncatable primes: Difference between revisions

Added Quackery.
(Removed "initSet". Changed "toSet" for "toHashSet". Other minor changes.)
(Added Quackery.)
Line 2,918:
'''Sample Output'''
<pre>(998443, 739399)</pre>
 
=={{header|Quackery}}==
 
<code>eratosthenes</code> and <code>sieve</code> are defined at [[Sieve of Eratosthenes#Quackery]].
 
<lang Quackery> 1000000 eratosthenes
 
[ false swap
number$ witheach
[ char 0 =
if [ conclude not ] ] ] is haszero ( n --> b )
 
[ 10 / ] is truncright ( n --> n )
 
[ number$
behead drop $->n drop ] is truncleft ( n --> n )
 
[ dup isprime not iff
[ drop false ] done
dup haszero iff
[ drop false ] done
true swap
[ truncleft
dup 0 > while
dup isprime not iff
[ dip not ] done
again ] drop ] is ltruncatable ( n --> b )
 
[ dup isprime not iff
[ drop false ] done
dup haszero iff
[ drop false ] done
true swap
[ truncright
dup 0 > while
dup isprime not iff
[ dip not ] done
again ] drop ] is rtruncatable ( n --> b )
 
say "Left: "
1000000 times [ i ltruncatable if [ i echo conclude ] ]
cr
say "Right: "
1000000 times [ i rtruncatable if [ i echo conclude ] ]
cr</lang>
 
{{out}}
 
<pre>Left: 998443
Right: 739399
</pre>
 
=={{header|Racket}}==
1,483

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.