Find numbers n in base 2 where n is prime and all it's digits are 1: Difference between revisions
Content added Content deleted
No edit summary |
(Add Factor) |
||
Line 4: | Line 4: | ||
Find numbers n in base 2 where n is prime and all it's digits are 1 |
Find numbers n in base 2 where n is prime and all it's digits are 1 |
||
<br>Let 1 < n < 10000 |
<br>Let 1 < n < 10000 |
||
=={{header|Factor}}== |
|||
Numbers in base 2 whose digits are all 1: also known as the powers of 2 minus 1. |
|||
<lang factor>USING: lists lists.lazy math math.primes prettyprint ; |
|||
2 lfrom [ 2^ 1 - ] <lazy-map> [ prime? ] lfilter [ 10,000 < ] lwhile list>array .</lang> |
|||
{{out}} |
|||
<pre> |
|||
{ 3 7 31 127 8191 } |
|||
</pre> |
|||
=={{header|Ring}}== |
=={{header|Ring}}== |