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.

Showing 1-4 of 4 results.

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

Original entry on oeis.org

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, 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, 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
Offset: 1

Views

Author

Amarnath Murthy, Jul 17 2005

Keywords

Comments

Erdős conjectures that the numbers in A039669 are the only n for which n-2^r is prime for all 2^rT. D. Noe and Robert G. Wilson v, Jul 19 2005
a(A006285(n)) = 0. - Reinhard Zumkeller, May 27 2015

Examples

			a(21) = 4, 21-2 =19, 21-4 = 17, 21-8 = 13, 21-16 = 5, four primes.
127 is the smallest odd number > 1 such that a(n) = 0: A006285(2) = 127. - _Reinhard Zumkeller_, May 27 2015
		

Crossrefs

Programs

  • Haskell
    a109925 n = sum $ map (a010051' . (n -)) $ takeWhile (< n)  a000079_list
    -- Reinhard Zumkeller, May 27 2015
    
  • 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
    
  • Maple
    A109925 := proc(n)
        a := 0 ;
        for k from 0 do
            if n-2^k < 2 then
                return a ;
            elif isprime(n-2^k) then
                a := a+1 ;
            end if;
        end do:
    end proc:
    seq(A109925(n),n=1..80) ; # R. J. Mathar, Mar 07 2022
  • Mathematica
    Table[cnt=0; r=1; While[rRobert G. Wilson v, Jul 21 2005 *)
    Table[Count[n - 2^Range[0, Floor[Log2[n]]], ?PrimeQ], {n, 110}] (* _Harvey P. Dale, Oct 21 2024 *)
  • PARI
    a(n)=sum(k=0,log(n)\log(2),isprime(n-2^k)) \\ Charles R Greathouse IV, Feb 19 2013
    
  • Python
    from sympy import isprime
    def A109925(n): return sum(1 for i in range(n.bit_length()) if isprime(n-(1<Chai Wah Wu, Nov 29 2023

Formula

a(A118954(n))=0, a(A118955(n))>0; A118952(n)<=a(n); A078687(n)=a(A000040(n)). - Reinhard Zumkeller, May 07 2006
G.f.: ( Sum_{i>=0} x^(2^i) ) * ( Sum_{j>=1} x^prime(j) ). - Ilya Gutkovskiy, Feb 10 2022

Extensions

Corrected and extended by T. D. Noe and Robert G. Wilson v, Jul 19 2005

A118957 Numbers of the form 2^k + p, where p is a prime less than 2^k.

Original entry on oeis.org

6, 7, 10, 11, 13, 15, 18, 19, 21, 23, 27, 29, 34, 35, 37, 39, 43, 45, 49, 51, 55, 61, 63, 66, 67, 69, 71, 75, 77, 81, 83, 87, 93, 95, 101, 105, 107, 111, 117, 123, 125, 130, 131, 133, 135, 139, 141, 145, 147, 151, 157, 159, 165, 169, 171, 175, 181, 187, 189, 195, 199
Offset: 1

Views

Author

Reinhard Zumkeller, May 07 2006

Keywords

Crossrefs

Complement of A118956; subsequence of A118955.

Programs

  • Maple
    isA118957 := proc(n)
        local twok,p ;
        twok := 1 ;
        while twok < n-1 do
            p := n-twok ;
            if isprime(p) and p < twok then
                return true;
            end if;
            twok := twok*2 ;
        end do:
        return false;
    end proc:
    for n from 1 to 200 do
        if isA118957(n) then
            printf("%d,",n) ;
        end if;
    end do: # R. J. Mathar, Feb 27 2015
  • Mathematica
    okQ[n_] := Module[{k, p}, For[k = Ceiling[Log[2, n]], k>1, k--, p = n-2^k; If[2 <= p < 2^k && PrimeQ[p], Return[True]]]; False]; Select[Range[200], okQ] (* Jean-François Alcover, Mar 11 2019 *)
  • PARI
    is(n)=isprime(n-2^logint(n,2)) \\ Charles R Greathouse IV, Sep 01 2015; edited Jan 24 2024
    
  • Python
    from sympy import primepi
    def A118957(n):
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            kmin = kmax >> 1
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        def f(x): return n+x-sum(primepi(min(x-(m:=1<Chai Wah Wu, Feb 23 2025

Formula

A118952(a(n)) = 1.

A118953 Number of ways to write the n-th prime as 2^k + p, where p is prime and p < 2^k.

Original entry on oeis.org

0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1
Offset: 1

Views

Author

Reinhard Zumkeller, May 07 2006

Keywords

Comments

0 <= a(n) <= 1, a(n) <= A078687(n);
a(A049084(A118958(n))) = 0, a(A049084(A091932(n))) = 1;
a(n) = A118952(A000040(n)).

A118956 Numbers that cannot be written as 2^k + p with p prime < 2^k.

Original entry on oeis.org

1, 2, 3, 4, 5, 8, 9, 12, 14, 16, 17, 20, 22, 24, 25, 26, 28, 30, 31, 32, 33, 36, 38, 40, 41, 42, 44, 46, 47, 48, 50, 52, 53, 54, 56, 57, 58, 59, 60, 62, 64, 65, 68, 70, 72, 73, 74, 76, 78, 79, 80, 82, 84, 85, 86, 88, 89, 90, 91, 92, 94, 96, 97, 98, 99, 100, 102, 103, 104, 106
Offset: 1

Views

Author

Reinhard Zumkeller, May 07 2006

Keywords

Comments

Complement of A118957.
A118954 is a subsequence.

Crossrefs

Programs

  • Mathematica
    nn=15;Complement[Range[nn^2],Flatten[Table[c=2^n;c+Prime[ Range[ PrimePi[ c]]],{n,2,nn}]]] (* Harvey P. Dale, Sep 14 2012 *)
  • Python
    from sympy import primepi
    def A118956(n):
        def f(x): return int(n+sum(primepi(min(x-(m:=1<Chai Wah Wu, Feb 23 2025

Formula

A118952(a(n)) = 0.
Showing 1-4 of 4 results.