Increasing gaps between consecutive Niven numbers: Difference between revisions

Added XPL0 example.
No edit summary
(Added XPL0 example.)
Line 2,367:
32 276 1,039,028,518 18,879,988,824</pre>
 
=={{header|XPL0}}==
{{trans|11l}}
<syntaxhighlight lang "XPL0">func DigitSum(N, Sum); \Return sum of digits in N given sum of digits in N-1
int N, Sum;
[Sum:= Sum+1;
while N > 0 and rem(N/10) = 0 do
[Sum:= Sum -9;
N:= N/10;
];
return Sum;
];
 
int Previous, Gap, S, NivenIndex, GapIndex, Niven;
def Tab = 9;
 
[Previous:= 1;
Gap:= 0;
S:= 0;
NivenIndex:= 0;
GapIndex:= 1;
 
Text(0, "Index Gap Index Niven^m^j");
 
Niven:= 1;
 
while GapIndex <= 23 do
[S:= DigitSum(Niven, S);
if rem(Niven/S) = 0 then
[if Niven > Previous + Gap then
[Gap:= Niven - Previous;
IntOut(0, GapIndex); ChOut(0, Tab);
IntOut(0, Gap); ChOut(0, Tab);
IntOut(0, NivenIndex); ChOut(0, Tab);
IntOut(0, Previous); CrLf(0);
GapIndex:= GapIndex+1;
];
Previous:= Niven;
NivenIndex:= NivenIndex+1;
];
Niven:= Niven+1;
];
]</syntaxhighlight>
{{out}}
<pre>
Index Gap Index Niven
1 1 1 1
2 2 10 10
3 6 11 12
4 7 26 63
5 8 28 72
6 10 32 90
7 12 83 288
8 14 102 378
9 18 143 558
10 23 561 2889
11 32 716 3784
12 36 1118 6480
13 44 2948 19872
14 45 4194 28971
15 54 5439 38772
16 60 33494 297864
17 66 51544 478764
18 72 61588 589860
19 88 94748 989867
20 90 265336 2879865
21 99 800054 9898956
22 108 3750017 49989744
23 126 6292149 88996914
</pre>
 
=={{header|Yabasic}}==
Line 2,411 ⟶ 2,480:
Igual que la entrada de FreeBASIC.
</pre>
 
 
=={{header|zkl}}==
291

edits