RosettaCodeData/Task/Population-count/Quackery/population-count.quackery
2023-07-01 13:44:08 -04:00

32 lines
753 B
Text

[ 0 swap
[ dup while
dup 1 &
rot + swap
1 >>
again ]
drop ] is popcount ( n --> n )
[ 1 & ] is odd ( n --> b )
[ odd not ] is even ( n --> b )
[ ]'[ temp put 0
[ over while
[ dup popcount
temp share do
if [ dup echo sp
dip [ 1 - ] ]
1+ ]
again ]
2drop temp release ] is echopopwith ( n --> )
say "Population counts of the first thirty powers of 3." cr
30 times
[ 3 i^ ** popcount echo sp ] cr
cr
say "The first thirty evil numbers." cr
30 echopopwith even cr
cr
say "The first thirty odious numbers." cr
30 echopopwith odd cr