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