Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #41 Oct 21 2024 12:29:07
%S 0,0,1,2,1,2,2,1,2,1,2,1,2,1,3,0,1,2,3,1,4,0,2,1,2,0,3,0,1,1,2,1,3,1,
%T 3,0,2,1,4,0,1,1,2,1,5,0,2,1,3,0,3,0,1,1,3,0,2,0,1,1,3,1,4,0,1,1,2,1,
%U 5,0,2,1,2,1,6,0,3,0,2,1,3,0,3,1,2,0,4,0,1,1,3,0,3,0,2,0,1,1,3,0,2,1,2,1,6
%N Number of primes of the form n - 2^k.
%C Erdős conjectures that the numbers in A039669 are the only n for which n-2^r is prime for all 2^r<n. - _T. D. Noe_ and _Robert G. Wilson v_, Jul 19 2005
%C a(A006285(n)) = 0. - _Reinhard Zumkeller_, May 27 2015
%H T. D. Noe, <a href="/A109925/b109925.txt">Table of n, a(n) for n = 1..10000</a>
%F a(A118954(n))=0, a(A118955(n))>0; A118952(n)<=a(n); A078687(n)=a(A000040(n)). - _Reinhard Zumkeller_, May 07 2006
%F G.f.: ( Sum_{i>=0} x^(2^i) ) * ( Sum_{j>=1} x^prime(j) ). - _Ilya Gutkovskiy_, Feb 10 2022
%e a(21) = 4, 21-2 =19, 21-4 = 17, 21-8 = 13, 21-16 = 5, four primes.
%e 127 is the smallest odd number > 1 such that a(n) = 0: A006285(2) = 127. - _Reinhard Zumkeller_, May 27 2015
%p A109925 := proc(n)
%p a := 0 ;
%p for k from 0 do
%p if n-2^k < 2 then
%p return a ;
%p elif isprime(n-2^k) then
%p a := a+1 ;
%p end if;
%p end do:
%p end proc:
%p seq(A109925(n),n=1..80) ; # _R. J. Mathar_, Mar 07 2022
%t Table[cnt=0; r=1; While[r<n, If[PrimeQ[n-r], cnt++ ]; r=2r]; cnt, {n, 150}] (Noe)
%t f[n_] := Count[ PrimeQ[n - 2^Range[0, Floor[ Log[2, n]]]], True]; Table[ f[n], {n, 105}] (* _Robert G. Wilson v_, Jul 21 2005 *)
%t Table[Count[n - 2^Range[0, Floor[Log2[n]]], _?PrimeQ], {n, 110}] (* _Harvey P. Dale_, Oct 21 2024 *)
%o (Magma) a109925:=function(n); count:=0; e:=1; while e le n do if IsPrime(n-e) then count+:=1; end if; e*:=2; end while; return count; end function; [ a109925(n): n in [1..105] ]; // _Klaus Brockhaus_, Oct 30 2010
%o (PARI) a(n)=sum(k=0,log(n)\log(2),isprime(n-2^k)) \\ _Charles R Greathouse IV_, Feb 19 2013
%o (Haskell)
%o a109925 n = sum $ map (a010051' . (n -)) $ takeWhile (< n) a000079_list
%o -- _Reinhard Zumkeller_, May 27 2015
%o (Python)
%o from sympy import isprime
%o def A109925(n): return sum(1 for i in range(n.bit_length()) if isprime(n-(1<<i))) # _Chai Wah Wu_, Nov 29 2023
%Y Cf. A039669, A109926, A175956, A156695.
%Y Cf. A000079, A000040, A010051, A006285.
%Y Cf. A118954, A118955, A118952, A078687.
%K easy,nonn
%O 1,4
%A _Amarnath Murthy_, Jul 17 2005
%E Corrected and extended by _T. D. Noe_ and _Robert G. Wilson v_, Jul 19 2005