Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Population-count/Quackery/population-count.quackery
Normal file
32
Task/Population-count/Quackery/population-count.quackery
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
[ 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue