Pernicious numbers: Difference between revisions

→‎{{header|Quackery}}: reused code from population count
m (added highlighting.)
(→‎{{header|Quackery}}: reused code from population count)
Line 2,161:
=={{header|Quackery}}==
 
<lang Quackery> [ $ "rosetta/seive.qky" loadfile ] now!
$ "rosetta/popcount.qky" loadfile ] now!
 
( i.e. using the code from )
( http://rosettacode.org/wiki/Sieve_of_Eratosthenes and )
( http://rosettacode.org/wiki/Population_count )
 
29 eratosthenes ( Precompute as many primes as are required )
Line 2,170 ⟶ 2,172:
( number less than (2^30)-1 so primes up to )
( 29 will suffice. )
 
[ 0 swap
[ dup while
dup 1 &
rot + swap
1 >>
again ]
drop ] is bitcount ( n --> n )
 
[ bitcount isprime ] is pernicious ( n --> b )
 
[ 0
[ over while
[ dup pernicious
if [ dup echo sp
dip [ 1 - ] ]
1+ ]
again ]
2drop ] is perniciousnumbers ( n --> )
 
[ 1+ over - times
[ dup i^ +
dup pernicious iffpopcount
isprime 1+ ]iff
[ echo sp ]
else drop ]
drop ] is perniciousrange ( n n --> )
 
25 echopopwith isprime cr
 
25 perniciousnumbers cr
888888877 888888888 perniciousrange cr</lang>
 
888888877 888888888 perniciousrange cr</lang>
 
{{out}}
1,462

edits