cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A109925 Number of primes of the form n - 2^k.

This page as a plain text file.
%I A109925 #44 Sep 05 2025 11:22:36
%S A109925 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 A109925 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 A109925 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 A109925 Number of primes of the form n - 2^k.
%C A109925 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 A109925 a(A006285(n)) = 0. - _Reinhard Zumkeller_, May 27 2015
%H A109925 T. D. Noe, <a href="/A109925/b109925.txt">Table of n, a(n) for n = 1..10000</a>
%H A109925 Thomas Bloom, <a href="https://www.erdosproblems.com/236">Let f(n) count the number of solutions to n = p + 2^k for prime p and k >= 0. Is it true that f(n) = o(log n)?</a>, Erdős Problems.
%H A109925 Terence Tao, <a href="https://github.com/teorth/erdosproblems/blob/main/README.md#table">Erdős problem database</a>, see no. 236.
%F A109925 a(A118954(n))=0, a(A118955(n))>0; A118952(n)<=a(n); A078687(n)=a(A000040(n)). - _Reinhard Zumkeller_, May 07 2006
%F A109925 G.f.: ( Sum_{i>=0} x^(2^i) ) * ( Sum_{j>=1} x^prime(j) ). - _Ilya Gutkovskiy_, Feb 10 2022
%e A109925 a(21) = 4, 21-2 =19, 21-4 = 17, 21-8 = 13, 21-16 = 5, four primes.
%e A109925 127 is the smallest odd number > 1 such that a(n) = 0: A006285(2) = 127. - _Reinhard Zumkeller_, May 27 2015
%p A109925 A109925 := proc(n)
%p A109925     a := 0 ;
%p A109925     for k from 0 do
%p A109925         if n-2^k < 2 then
%p A109925             return a ;
%p A109925         elif isprime(n-2^k) then
%p A109925             a := a+1 ;
%p A109925         end if;
%p A109925     end do:
%p A109925 end proc:
%p A109925 seq(A109925(n),n=1..80) ; # _R. J. Mathar_, Mar 07 2022
%t A109925 Table[cnt=0; r=1; While[r<n, If[PrimeQ[n-r], cnt++ ]; r=2r]; cnt, {n, 150}] (Noe)
%t A109925 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 A109925 Table[Count[n - 2^Range[0, Floor[Log2[n]]], _?PrimeQ], {n, 110}] (* _Harvey P. Dale_, Oct 21 2024 *)
%o A109925 (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 A109925 (PARI) a(n)=sum(k=0,log(n)\log(2),isprime(n-2^k)) \\ _Charles R Greathouse IV_, Feb 19 2013
%o A109925 (Haskell)
%o A109925 a109925 n = sum $ map (a010051' . (n -)) $ takeWhile (< n)  a000079_list
%o A109925 -- _Reinhard Zumkeller_, May 27 2015
%o A109925 (Python)
%o A109925 from sympy import isprime
%o A109925 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 A109925 Cf. A039669, A109926, A175956, A156695.
%Y A109925 Cf. A000079, A000040, A010051, A006285.
%Y A109925 Cf. A118954, A118955, A118952, A078687.
%K A109925 easy,nonn,changed
%O A109925 1,4
%A A109925 _Amarnath Murthy_, Jul 17 2005
%E A109925 Corrected and extended by _T. D. Noe_ and _Robert G. Wilson v_, Jul 19 2005