A283806 Odd numbers which are uniquely decomposable into the sum of a prime and a power of two.
3, 5, 17, 29, 41, 53, 59, 65, 89, 97, 119, 137, 163, 179, 185, 191, 193, 209, 217, 219, 221, 223, 233, 239, 247, 253, 269, 281, 305, 307, 311, 343, 359, 389, 403, 407, 415, 419, 427, 431, 457, 491, 505, 521, 533, 545, 547, 557, 569, 575, 581, 583, 597, 613, 637
Offset: 1
Examples
17 is in the sequence since 17 - 2^2 = 13 is a prime and 17 - 2^0 = 16, 17 - 2^1 = 15, 17 - 2^3 = 9, 17 - 2^4 = 1 are all nonprimes.
Links
- Robert G. Wilson v, Table of n, a(n) for n = 1..1000
- Wikipedia, Prime number
Programs
-
Magma
lst:=[]; for n in [1..637 by 2] do c:=0; r:=Floor(Log(n)/Log(2)); for x in [0..r] do a:=n-2^x; if IsPrime(a) then c+:=1; end if; if c eq 2 then break; end if; end for; if c eq 1 then Append(~lst, n); end if; end for; lst;
-
Mathematica
Select[Range[1, 640, 2], Function[n, Total@ Boole@ PrimeQ@ Map[n - # &, 2^Range[0, Floor@ Log2@ n]] == 1]] (* Michael De Vlieger, Mar 18 2017 *)
-
PARI
isok(n) = (n % 2) && (sum(k=0, log(n)\log(2), isprime(n-2^k)) == 1); \\ Michel Marcus, Mar 18 2017
-
Python
from sympy import isprime import math print([n for n in range(1001) if n%2 and sum([isprime(n-2**k) for k in range(int(math.floor(math.log(n)/math.log(2))) + 1)]) == 1]) # Indranil Ghosh, Mar 29 2017
Formula
a(n) ~ 10*(n + n/log(n)).
Comments