Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
21
Task/Population-count/Maxima/population-count.maxima
Normal file
21
Task/Population-count/Maxima/population-count.maxima
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
popcount(n) := block(
|
||||
bits: makelist(bit_onep(n, i), i, 0, bit_length(n)),
|
||||
length(sublist(bits, "+"))
|
||||
)$
|
||||
|
||||
makelist(popcount(3^i), i, 0, 29);
|
||||
|
||||
evilp(n) := evenp(popcount(n))$
|
||||
|
||||
odiousp(n) := oddp(popcount(n))$
|
||||
|
||||
firstnums(lim, pred, name) := block(
|
||||
sprint("First", lim, name, "numbers:"),
|
||||
newline(),
|
||||
count: 0, n: 0, while count<lim do(
|
||||
if pred(n) then block(sprint(n), count: count+1),
|
||||
n: n+1))$
|
||||
|
||||
firstnums(30, evilp, "evil")$
|
||||
|
||||
firstnums(30, odiousp, "odious")$
|
||||
Loading…
Add table
Add a link
Reference in a new issue