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.

A288574 Total number of distinct primes in all representations of 2*n+1 as a sum of 3 odd primes.

Original entry on oeis.org

0, 0, 0, 0, 1, 2, 4, 4, 6, 7, 9, 10, 12, 15, 17, 16, 19, 19, 23, 25, 26, 26, 28, 33, 32, 35, 43, 39, 41, 45, 45, 48, 54, 55, 52, 60, 59, 56, 75, 67, 67, 81, 74, 76, 92, 83, 85, 100, 96, 81, 106, 103, 91, 121, 108, 98, 131, 120, 116, 143, 133, 129, 151, 144, 124, 163
Offset: 0

Views

Author

Keywords

Comments

That is, a representation 2n+1 = p+p+p counts as 1, as p+p+q counts as 2, and p+q+r counts as 3. If each representation is counted once, we simply get A007963.

Crossrefs

A288573 appears to be an erroneous version of this sequence.

Programs

  • Maple
    A288574 := proc(n)
        local a, i, j, k, p, q, r,pqr ;
        a := 0 ;
        for i from 2 do
            p := ithprime(i) ;
            for j from i do
                q := ithprime(j) ;
                for k from j do
                    r := ithprime(k) ;
                    if p+q+r = 2*n+1 then
                        pqr := {p,q,r} ;
                        a := a+nops(pqr) ;
                    elif p+q+r > 2*n+1 then
                        break;
                    end if;
                end do:
                if p+2*q > 2*n+1 then
                    break;
                end if;
            end do:
            if 3*p > 2*n+1 then
                break;
            end if;
        end do:
        return a;
    end proc:
    seq(A288574(n),n=0..80) ; # R. J. Mathar, Jun 29 2017
  • Mathematica
    Table[x = 2 n + 1; max = PrimePi[x]; Total[Length /@ Tally /@ DeleteDuplicates[Sort /@ Select[Tuples[Range[2, max], 3], Prime[#[[1]]] + Prime[#[[2]]] + Prime[#[[3]]] == x &]]], {n, 0, 100}] (* Robert Price, Apr 22 2025 *)
  • PARI
    a(n)={my(p,q,r,cnt);n=2*n+1;
    forprime(p=3,n\3,forprime(q=p,(n-p)\2,
    if(isprime(r=n-p-q), cnt+=if(p===q&&p==r,1,if(p==q||q==r,2,3)))));cnt}
    \\ Franklin T. Adams-Watters, Jun 28 2017
    
  • Python
    from sympy import primerange, isprime
    def a(n):
        n=2*n + 1
        c=0
        for p in primerange(3, n//3 + 1):
            for q in primerange(p, (n - p)//2 + 1):
                r=n - p - q
                if isprime(r): c+=1 if p==q and p==r else 2 if p==q or q==r else 3
        return c
    print([a(n) for n in range(66)]) # Indranil Ghosh, Jun 29 2017