Self numbers: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
(Added XPL0 example.) |
||
Line 2,192: | Line 2,192: | ||
The 100 millionth self number is 1022727208 |
The 100 millionth self number is 1022727208 |
||
Took 222.789713 seconds. |
Took 222.789713 seconds. |
||
</pre> |
|||
=={{header|XPL0}}== |
|||
{{trans|Go}} |
|||
As run on Raspberry Pi4. |
|||
<syntaxhighlight lang "XPL0">def LenSV = 2_000_000_000 + 9*9 + 1; |
|||
func Sieve; |
|||
char SV; |
|||
int N, S(8), A, B, C, D, E, F, G, H, I, J; |
|||
[SV:= MAlloc(LenSV); |
|||
N:= 0; |
|||
for A:= 0 to 1 do |
|||
[for B:= 0 to 9 do |
|||
[S(0):= A + B; |
|||
for C:= 0 to 9 do |
|||
[S(1):= S(0) + C; |
|||
for D:= 0 to 9 do |
|||
[S(2):= S(1) + D; |
|||
for E:= 0 to 9 do |
|||
[S(3):= S(2) + E; |
|||
for F:= 0 to 9 do |
|||
[S(4):= S(3) + F; |
|||
for G:= 0 to 9 do |
|||
[S(5):= S(4) + G; |
|||
for H:= 0 to 9 do |
|||
[S(6):= S(5) + H; |
|||
for I:= 0 to 9 do |
|||
[S(7):= S(6) + I; |
|||
for J:= 0 to 9 do |
|||
[SV(S(7)+J+N):= true; |
|||
N:= N+1; |
|||
] |
|||
] |
|||
] |
|||
] |
|||
] |
|||
] |
|||
] |
|||
] |
|||
] |
|||
]; |
|||
return SV; |
|||
]; |
|||
char SV; |
|||
int ST, Count, I; |
|||
[ST:= GetTime; |
|||
SV:= Sieve; |
|||
Count:= 0; |
|||
Text(0, "The first 50 self numbers are:^m^j"); |
|||
for I:= 0 to LenSV-1 do |
|||
[if SV(I) = false then |
|||
[Count:= Count+1; |
|||
if Count <= 50 then |
|||
[IntOut(0, I); ChOut(0, ^ )]; |
|||
if Count = 100_000_000 then |
|||
[Text(0, "^m^j^m^jThe 100 millionth self number is "); |
|||
IntOut(0, I); |
|||
CrLf(0); |
|||
I:= LenSV; |
|||
]; |
|||
]; |
|||
]; |
|||
Text(0, "Took "); RlOut(0, float(GetTime-ST) / 1e6); CrLf(0); |
|||
]</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
The first 50 self numbers are: |
|||
1 3 5 7 9 20 31 42 53 64 75 86 97 108 110 121 132 143 154 165 176 187 198 209 211 222 233 244 255 266 277 288 299 310 312 323 334 345 356 367 378 389 400 411 413 424 435 446 457 468 |
|||
The 100 millionth self number is 1022727208 |
|||
Took 29.46575 |
|||
</pre> |
</pre> |