Honaker primes: Difference between revisions

Content added Content deleted
(added Arturo)
Line 791: Line 791:


Ten thousandth: (286069, 4043749)</pre>
Ten thousandth: (286069, 4043749)</pre>
=={{header|Ruby}}==
<syntaxhighlight lang="ruby" line>require 'prime'

honakers = Prime.each.with_index(1).lazy.select{|pr, i| pr.digits.sum == i.digits.sum}
ar = honakers.take(10_000).to_a
puts "The first 50 Honaker primes and their position:"
ar.first(50).each_slice(5){|slice| puts "%15s"*slice.size % slice}

puts "\nHonaker prime 10000 is %d on position %i." % ar.last</syntaxhighlight>
{{out}}
<pre>The first 50 Honaker primes:
[131, 32] [263, 56] [457, 88] [1039, 175] [1049, 176]
[1091, 182] [1301, 212] [1361, 218] [1433, 227] [1571, 248]
[1913, 293] [1933, 295] [2141, 323] [2221, 331] [2273, 338]
[2441, 362] [2591, 377] [2663, 386] [2707, 394] [2719, 397]
[2729, 398] [2803, 409] [3067, 439] [3137, 446] [3229, 457]
[3433, 481] [3559, 499] [3631, 508] [4091, 563] [4153, 571]
[4357, 595] [4397, 599] [4703, 635] [4723, 637] [4903, 655]
[5009, 671] [5507, 728] [5701, 751] [5711, 752] [5741, 755]
[5801, 761] [5843, 767] [5927, 779] [6301, 820] [6311, 821]
[6343, 826] [6353, 827] [6553, 847] [6563, 848] [6653, 857]

Honaker prime 10000 is 4043749 on position 286069.
</pre>


=={{header|Rust}}==
=={{header|Rust}}==