23 lines
518 B
Text
23 lines
518 B
Text
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);
|
|
]
|