Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Perfect-numbers/XPL0/perfect-numbers.xpl0
Normal file
18
Task/Perfect-numbers/XPL0/perfect-numbers.xpl0
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
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)];
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue