Increasing gaps between consecutive Niven numbers: Difference between revisions
Content deleted Content added
→{{header|Ruby}}: Add Ruby |
|||
Line 1,678:
{{out|output|text= is identical to the 1<sup>st</sup> REXX version.}} <br><br> !-->
=={{header|Ruby}}==
<lang ruby>nivens = Enumerator.new {|y| (1..).each {|n| y << n if n.remainder(n.digits.sum).zero?} }
cur_gap = 0
puts 'Gap Index of gap Starting Niven'
nivens.each_cons(2).with_index(1) do |(n1, n2), i|
break if i > 10_000_000
if n2-n1 > cur_gap then
printf "%3d %15s %15s\n", n2-n1, i, n1
cur_gap = n2-n1
end
end
</lang>
{{out}}
<pre>Gap Index of gap Starting Niven
1 1 1
2 10 10
6 11 12
7 26 63
8 28 72
10 32 90
12 83 288
14 102 378
18 143 558
23 561 2889
32 716 3784
36 1118 6480
44 2948 19872
45 4194 28971
54 5439 38772
60 33494 297864
66 51544 478764
72 61588 589860
88 94748 989867
90 265336 2879865
99 800054 9898956
108 3750017 49989744
126 6292149 88996914
</pre>
=={{header|Rust}}==
<lang rust>// [dependencies]
|