18 lines
389 B
Text
18 lines
389 B
Text
include c:\cxpl\codes; \intrinsic 'code' declarations
|
|
|
|
func Perfect(N); \Return 'true' if N is a perfect number
|
|
int N, S, I, Q;
|
|
[S:= 1;
|
|
for I:= 2 to sqrt(N) do
|
|
[Q:= N/I;
|
|
if rem(0)=0 then S:= S+I+Q;
|
|
];
|
|
return S=N & N#1;
|
|
];
|
|
|
|
int A, N;
|
|
[for A:= 1 to 16 do
|
|
[N:= (1<<A - 1) * 1<<(A-1);
|
|
if Perfect(N) then [IntOut(0, N); CrLf(0)];
|
|
];
|
|
]
|