Increasing gaps between consecutive Niven numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|Wren}}: Minor tidy)
(Added Easylang)
Line 672: Line 672:
</pre>
</pre>



=={{header|EasyLang}}==
{{trans|C}}
<syntaxhighlight>
func digsum n sum .
sum += 1
while n > 0 and n mod 10 = 0
sum -= 9
n = n div 10
.
return sum
.
func divisible n d .
if d mod 2 = 0 and n mod 2 = 1
return 0
.
return if n mod d = 0
.
numfmt 0 8
previous = 1
print " Gap index Gap Niven index Niven number"
print " --------- --- ----------- ------------"
for niven = 1 to 10000000
sum = digsum niven sum
if divisible niven sum = 1
if niven > previous + gap
gap_index += 1
gap = niven - previous
print gap_index & gap & " " & niven_index & " " & previous
.
previous = niven
niven_index += 1
.
.
</syntaxhighlight>
{{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
</pre>


=={{header|Fortran}}==
=={{header|Fortran}}==
Line 788: Line 849:
31 258 547,594,831 9,879,997,824
31 258 547,594,831 9,879,997,824
32 276 1,039,028,518 18,879,988,824</pre>
32 276 1,039,028,518 18,879,988,824</pre>



=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==