Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Hamming-numbers/XPL0/hamming-numbers.xpl0
Normal file
23
Task/Hamming-numbers/XPL0/hamming-numbers.xpl0
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
func Hamming(N); \Return 'true' if N is a Hamming number
|
||||
int N;
|
||||
[if N = 1 then return true;
|
||||
if rem(N/2) = 0 then return Hamming(N/2);
|
||||
if rem(N/3) = 0 then return Hamming(N/3);
|
||||
if rem(N/5) = 0 then return Hamming(N/5);
|
||||
return false;
|
||||
];
|
||||
|
||||
int N, C;
|
||||
[N:= 1; C:= 0;
|
||||
loop [if Hamming(N) then
|
||||
[C:= C+1;
|
||||
IntOut(0, N); ChOut(0, ^ );
|
||||
if C >= 20 then quit;
|
||||
];
|
||||
N:= N+1;
|
||||
];
|
||||
CrLf(0);
|
||||
N:= 1<<31; \ 8-)
|
||||
repeat N:= N-1 until Hamming(N);
|
||||
IntOut(0, N);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue