17 lines
470 B
Text
17 lines
470 B
Text
popcount(n) := block(
|
|
bits: makelist(bit_onep(n, i), i, 0, bit_length(n)),
|
|
length(sublist(bits, "+"))
|
|
)$
|
|
|
|
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))$
|
|
|
|
perniciousp(n) := primep(popcount(n))$
|
|
|
|
firstnums(25, perniciousp, "pernicious")$
|
|
|
|
sublist(makelist(i, i, 888888877, 888888888), perniciousp);
|