Increasing gaps between consecutive Niven numbers: Difference between revisions

Added 11l
(Added 11l)
Line 32:
:*   [https://cs.uwaterloo.ca/journals/JIS/VOL6/Doyon/doyon.pdf (PDF) version of the (above) article by Doyon].
<br><br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>F digit_sum(=n, =sum)
sum++
L n > 0 & n % 10 == 0
sum -= 9
n /= 10
R sum
 
V previous = 1
V gap = 0
V s = 0
V niven_index = 0
V gap_index = 1
 
print(‘Gap index Gap Niven index Niven number’)
 
V niven = 1
 
L gap_index <= 22
s = digit_sum(niven, s)
I niven % s == 0
I niven > previous + gap
gap = niven - previous
print(‘#9 #4 #13 #11’.format(gap_index, gap, niven_index, previous))
gap_index++
previous = niven
niven_index++
niven++</lang>
 
{{out}}
<pre>
Gap index Gap Niven index Niven number
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
</pre>
 
=={{header|AWK}}==
Line 98 ⟶ 156:
22 108 3750017 49989744
</pre>
 
 
=={{header|BASIC256}}==
1,481

edits