Mersenne primes: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) (added Arturo) |
(→{{header|Ruby}}: Add Ruby) |
||
Line 1,723: | Line 1,723: | ||
<pre> |
<pre> |
||
{ 2 3 5 7 13 17 19 31 } |
{ 2 3 5 7 13 17 19 31 } |
||
</pre> |
|||
=={{header|Ruby}}== |
|||
<syntaxhighlight lang="ruby">require 'openssl' |
|||
(0..).each{|n| puts "2**#{n} - 1" if OpenSSL::BN.new(2**n -1).prime? } |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre>2**2 - 1 |
|||
2**3 - 1 |
|||
2**5 - 1 |
|||
2**7 - 1 |
|||
2**13 - 1 |
|||
2**17 - 1 |
|||
2**19 - 1 |
|||
2**31 - 1 |
|||
2**61 - 1 |
|||
2**89 - 1 |
|||
2**107 - 1 |
|||
2**127 - 1 |
|||
2**521 - 1 |
|||
2**607 - 1 |
|||
2**1279 - 1 |
|||
2**2203 - 1 |
|||
2**2281 - 1 |
|||
2**3217 - 1 |
|||
2**4253 - 1 |
|||
^Ctest2.rb:7:in `prime?': Interrupt |
|||
</pre> |
</pre> |
||