Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Amicable-pairs/XPL0/amicable-pairs.xpl0
Normal file
27
Task/Amicable-pairs/XPL0/amicable-pairs.xpl0
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
func SumDiv(Num); \Return sum of proper divisors of Num
|
||||
int Num, Div, Sum, Quot;
|
||||
[Div:= 2;
|
||||
Sum:= 0;
|
||||
loop [Quot:= Num/Div;
|
||||
if Div > Quot then quit;
|
||||
if rem(0) = 0 then
|
||||
[Sum:= Sum + Div;
|
||||
if Div # Quot then Sum:= Sum + Quot;
|
||||
];
|
||||
Div:= Div+1;
|
||||
];
|
||||
return Sum+1;
|
||||
];
|
||||
|
||||
def Limit = 20000;
|
||||
int Tbl(Limit), N, M;
|
||||
[for N:= 0 to Limit-1 do
|
||||
Tbl(N):= SumDiv(N);
|
||||
for N:= 1 to Limit-1 do
|
||||
[M:= Tbl(N);
|
||||
if M<Limit & N=Tbl(M) & M>N then
|
||||
[IntOut(0, N); ChOut(0, 9\tab\);
|
||||
IntOut(0, M); CrLf(0);
|
||||
];
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue