Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,6 +0,0 @@
|
|||
with Interfaces;
|
||||
|
||||
package Population_Count is
|
||||
subtype Num is Interfaces.Unsigned_64;
|
||||
function Pop_Count(N: Num) return Natural;
|
||||
end Population_Count;
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
package body Population_Count is
|
||||
|
||||
function Pop_Count(N: Num) return Natural is
|
||||
use Interfaces;
|
||||
K5555: constant Unsigned_64 := 16#5555555555555555#;
|
||||
K3333: constant Unsigned_64 := 16#3333333333333333#;
|
||||
K0f0f: constant Unsigned_64 := 16#0f0f0f0f0f0f0f0f#;
|
||||
K0101: constant Unsigned_64 := 16#0101010101010101#;
|
||||
X: Unsigned_64 := N;
|
||||
begin
|
||||
X := X - (Shift_Right(X, 1) and k5555);
|
||||
X := (X and k3333) + (Shift_Right(X, 2) and k3333);
|
||||
X := (X + (Shift_Right(X, 4)) and K0f0f);
|
||||
X := Shift_Right((x * k0101), 56);
|
||||
return Natural(X);
|
||||
end Pop_Count;
|
||||
|
||||
end Population_Count;
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
with Ada.Text_IO, Population_Count; use Ada.Text_IO; use Population_Count;
|
||||
|
||||
procedure Test_Pop_Count is
|
||||
|
||||
X: Num; use type Num;
|
||||
|
||||
begin
|
||||
Put("Pop_Cnt(3**i):"); -- print pop_counts of powers of three
|
||||
X := 1; -- X=3**0
|
||||
for I in 1 .. 30 loop
|
||||
Put(Natural'Image(Pop_Count(X)));
|
||||
X := X * 3;
|
||||
end loop;
|
||||
New_Line;
|
||||
|
||||
Put("Evil: "); -- print first thirty evil numbers
|
||||
X := 0;
|
||||
for I in 1 .. 30 loop
|
||||
while Pop_Count(X) mod 2 /= 0 loop -- X is not evil
|
||||
X := X + 1;
|
||||
end loop;
|
||||
Put(Num'Image(X));
|
||||
X := X + 1;
|
||||
end loop;
|
||||
New_Line;
|
||||
|
||||
Put("Odious: "); -- print thirty oudous numbers
|
||||
X := 1;
|
||||
for I in 1 .. 30 loop
|
||||
while Pop_Count(X) mod 2 /= 1 loop -- X is not odious
|
||||
X := X + 1;
|
||||
end loop;
|
||||
Put(Num'Image(X));
|
||||
X := X + 1;
|
||||
end loop;
|
||||
New_Line;
|
||||
end Test_Pop_Count;
|
||||
Loading…
Add table
Add a link
Reference in a new issue