%I #26 Dec 18 2023 17:03:13
%S 3,4,5,7,9,15,21,45,75,105
%N Numbers n such that n - 2^k is a prime or 1 for all k satisfying 0 < k, 2^k < n.
%C Is the sequence finite?
%C Next term, if it exists, exceeds 5*10^9. - _Sean A. Irvine_, Dec 18 2023
%e 45 belongs to this sequence as 45-2, 45-4, 45-8, 45-16, 45-32, i.e., 43, 41, 37, 29 and 13 are all primes.
%t f[n_] := Block[{k = 1}, While[2^k < n, k++ ]; k--; k]; Do[ a = Table[n - 2^k, {k, 1, f[n]} ]; If[ a[[ -1]] == 1, a = Drop[a, -1]]; If[ Union[ PrimeQ[a]] == {True}, Print[n]], {n, 5, 10^7, 2} ]
%o (Python)
%o from sympy import isprime
%o def ok(n):
%o k, pow2 = 1, 2
%o while pow2 < n - 1:
%o if not isprime(n-pow2): return False
%o pow2 *= 2
%o return (2 < n)
%o print([m for m in range(1, 200) if ok(m)]) # _Michael S. Branicky_, Mar 04 2021
%Y Cf. A039669 (n-2^k is prime).
%K nonn,hard,more
%O 1,1
%A _Amarnath Murthy_, Feb 17 2002
%E Edited by _Robert G. Wilson v_, Feb 18 2002
|