Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
36
Task/Pernicious-numbers/XPL0/pernicious-numbers.xpl0
Normal file
36
Task/Pernicious-numbers/XPL0/pernicious-numbers.xpl0
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
func IsPrime(N); \Return 'true' if N is prime
|
||||
int N, D;
|
||||
[if N <= 2 then return N = 2;
|
||||
D:= 2;
|
||||
while D*D <= N do
|
||||
[if rem(N/D) = 0 then return false;
|
||||
D:= D+1;
|
||||
];
|
||||
return true;
|
||||
];
|
||||
|
||||
func BitCount(N); \Return number of set bits in N
|
||||
int N, C;
|
||||
[C:= 0;
|
||||
while N do
|
||||
[C:= C+1;
|
||||
N:= N & N-1;
|
||||
];
|
||||
return C;
|
||||
];
|
||||
|
||||
int N, C;
|
||||
[N:= 0; C:= 0;
|
||||
loop [if IsPrime(BitCount(N)) then
|
||||
[IntOut(0, N); ChOut(0, ^ );
|
||||
C:= C+1;
|
||||
if C >= 25 then quit;
|
||||
];
|
||||
N:= N+1;
|
||||
];
|
||||
CrLf(0);
|
||||
for N:= 888_888_877 to 888_888_888 do
|
||||
if IsPrime(BitCount(N)) then
|
||||
[IntOut(0, N); ChOut(0, ^ )];
|
||||
CrLf(0);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue