Ruth-Aaron numbers: Difference between revisions
Content added Content deleted
(J) |
(Added XPL0 example.) |
||
Line 807: | Line 807: | ||
First Ruth-Aaron triple (divisors): |
First Ruth-Aaron triple (divisors): |
||
89460294 |
89460294 |
||
</pre> |
|||
=={{header|XPL0}}== |
|||
<lang XPL0>func DivSum(N, AllDiv); \Return sum of divisors |
|||
int N, AllDiv; \all divisors vs. only prime divisors |
|||
int F, F0, S, Q; |
|||
[F:= 2; F0:= 0; S:= 0; |
|||
repeat Q:= N/F; |
|||
if rem(0) = 0 then |
|||
[if AllDiv then S:= S+F |
|||
else if F # F0 then |
|||
[S:= S+F; F0:= F]; |
|||
N:= Q; |
|||
] |
|||
else F:= F+1; |
|||
until F > N; |
|||
return S; |
|||
]; |
|||
proc Ruth(AllDiv); \Show Ruth-Aaron numbers |
|||
int AllDiv; |
|||
int C, S, S0, N; |
|||
[C:= 0; S0:= 0; |
|||
N:= 2; |
|||
repeat S:= DivSum(N, AllDiv); |
|||
if S = S0 then |
|||
[IntOut(0, N-1); |
|||
C:= C+1; |
|||
if rem(C/10) = 0 then CrLf(0) else ChOut(0, ^ ); |
|||
]; |
|||
S0:= S; |
|||
N:= N+1; |
|||
until C >= 30; |
|||
]; |
|||
[Ruth(true); |
|||
CrLf(0); |
|||
Ruth(false); |
|||
]</lang> |
|||
{{out}} |
|||
<pre> |
|||
5 8 15 77 125 714 948 1330 1520 1862 |
|||
2491 3248 4185 4191 5405 5560 5959 6867 8280 8463 |
|||
10647 12351 14587 16932 17080 18490 20450 24895 26642 26649 |
|||
5 24 49 77 104 153 369 492 714 1682 |
|||
2107 2299 2600 2783 5405 6556 6811 8855 9800 12726 |
|||
13775 18655 21183 24024 24432 24880 25839 26642 35456 40081 |
|||
</pre> |
</pre> |