Find adjacent primes which differ by a square integer: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add CLU) |
(→{{header|Ruby}}: Add Ruby) |
||
Line 848: | Line 848: | ||
</pre> |
</pre> |
||
=={{header|Ruby}}== |
|||
<lang ruby>require "prime" |
|||
Prime.each(1_000_000).each_cons(2) do |a, b| |
|||
diff = b - a |
|||
next unless diff > 36 |
|||
isqrt = Integer.sqrt(diff) |
|||
puts "#{b} - #{a} = #{diff}" if isqrt*isqrt == diff |
|||
end |
|||
</lang> |
|||
{{out}} |
|||
<pre>89753 - 89689 = 64 |
|||
107441 - 107377 = 64 |
|||
288647 - 288583 = 64 |
|||
368021 - 367957 = 64 |
|||
381167 - 381103 = 64 |
|||
396833 - 396733 = 100 |
|||
400823 - 400759 = 64 |
|||
445427 - 445363 = 64 |
|||
623171 - 623107 = 64 |
|||
625763 - 625699 = 64 |
|||
637067 - 637003 = 64 |
|||
710777 - 710713 = 64 |
|||
725273 - 725209 = 64 |
|||
779477 - 779413 = 64 |
|||
801947 - 801883 = 64 |
|||
803813 - 803749 = 64 |
|||
821741 - 821677 = 64 |
|||
832583 - 832519 = 64 |
|||
838349 - 838249 = 100 |
|||
844841 - 844777 = 64 |
|||
883871 - 883807 = 64 |
|||
912167 - 912103 = 64 |
|||
919511 - 919447 = 64 |
|||
954827 - 954763 = 64 |
|||
981887 - 981823 = 64 |
|||
997877 - 997813 = 64 |
|||
</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{libheader|Wren-math}} |
{{libheader|Wren-math}} |