A252168 Smallest k > 0 such that |(2n-1) - 2^k| is prime, or -1 if no such k exists.
2, 3, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 4, 1, 1, 2, 3, 1, 2, 1, 1, 2, 1, 2, 4, 1, 2, 4, 1, 1, 2, 3, 1, 2, 1, 1, 2, 3, 1, 2, 1, 2, 4, 1, 2, 4, 3, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 4, 3, 4, 4, 47, 1, 2, 1, 2, 6, 1, 1, 2, 3, 3, 8, 1, 1, 2, 3, 1, 2, 5, 1, 2, 1, 2, 4
Offset: 1
Examples
a(12) = 2 because 2*12-1 = 23 and that 23-2^1 = 21 is not prime but 23-2^2 = 19 is. a(69) = 6 because 2*69-1 = 137, |137-2^k| is composite for k = 1, 2, 3, 4, 5 and prime for k = 6. Even the smallest k can be also very large. For example, a(169) = 791. a(1147) > 65536.
Links
- Jinyuan Wang, Table of n, a(n) for n = 1..1146
Programs
-
Mathematica
Table[k = 1; While[!PrimeQ[Abs[(2*n-1) - 2^k]], k++]; k, {n, 1, 1000}]
-
PARI
A252168(n)={ my(k=1); n=2*n-1; while(!ispseudoprime(abs(n-2^k)), k++); k }
Extensions
a(19) corrected by Jinyuan Wang, Mar 25 2023
Comments