32 lines
723 B
Text
32 lines
723 B
Text
$ include "seed7_05.s7i";
|
|
|
|
const func integer: popcount (in integer: n) is
|
|
return card(bitset(n));
|
|
|
|
const proc: main is func
|
|
local
|
|
var integer: count is 0;
|
|
var integer: num is 0;
|
|
begin
|
|
for num range 0 to 29 do
|
|
write(popcount(3 ** num) <& " ");
|
|
end for;
|
|
writeln;
|
|
write("evil: ");
|
|
for num range 0 to integer.last until count >= 30 do
|
|
if not odd(popcount(num)) then
|
|
write(num <& " ");
|
|
incr(count);
|
|
end if;
|
|
end for;
|
|
writeln;
|
|
write("odious: ");
|
|
count := 0;
|
|
for num range 0 to integer.last until count >= 30 do
|
|
if odd(popcount(num)) then
|
|
write(num <& " ");
|
|
incr(count);
|
|
end if;
|
|
end for;
|
|
writeln;
|
|
end func;
|