A Woodall Prime is a prime which can be calculated, given a positive integer n
, with n * 2^n - 1
.
Your task is to, given a integer k
, generate a Woodall Prime with k
digits. If no such Woodall Prime exists, you must generate a Woodall Prime with the closest amount of digits. If two primes exist with the same digit count difference, you may use either.
You may assume that there exists no two Woodall Primes with the same amount of digits.
There is no time complexity limit, and you must be able to handle at least the first ten Woodall Primes (you can see them in the OEIS link at the start of the question)
You may write a full program or a function, and you may print or return the output.
Examples:
1 -> 7
4 -> 383
0 -> 7
-100 -> 7
7 -> 383 or 32212254719 (you may pick either of these)
8 -> 32212254719
As this is code-golf, that shortest code wins!
(there are only nine Woodall Primes on the linked OEIS sequence, so you might want to look at this for more Woodall Primes: https://oeis.org/A002234)
-100
digits mean? \$\endgroup\$7
is383 or 32212254719
someone may take that literally, you should change it to383 or 32212254719 (pick one)
. \$\endgroup\$