Smallest number k such that k+2^m is composite for all m less than k: Difference between revisions

(Added Go)
Line 83:
println(take(5, A033939)) # List: (773 2131 2491 4471 5101)
</lang>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
Since the code is reasonably performant I found the first 8 of this sequence:
<lang Mathematica>ClearAll[ValidK]
ValidK[1] := False
ValidK[k_] := If[EvenQ[k],
False,
AllTrue[Range[k - 1], CompositeQ[k + 2^#] &]
]
list = {};
Do[
If[ValidK[k],
AppendTo[list, k];
If[Length[list] >= 8, Break[]]
]
,
{k, 1, \[Infinity]}
]
list</lang>
{{out}}
<pre>{773, 2131, 2491, 4471, 5101, 7013, 8543, 10711}</pre>
 
=={{header|Perl}}==
1,111

edits