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-10 of 18 results. Next

A298990 Least number m such that A035026(m) = n.

Original entry on oeis.org

1, 2, 4, 5, 8, 11, 12, 17, 18, 37, 24, 53, 30, 89, 39, 71, 42, 101, 45, 179, 57, 137, 72, 193, 60, 233, 84, 257, 90, 251, 117, 401, 123, 311, 144, 373, 120, 347, 105, 457, 162, 661, 150, 479, 180, 547, 237, 599, 165, 617, 264, 641, 288, 683, 195, 907, 231, 881
Offset: 0

Views

Author

Seiichi Manyama, Jan 31 2018

Keywords

Comments

The upper branch visible in the scatterplot of the first terms corresponds to odd-indexed terms. - Rémy Sigrist, Jan 31 2018

Examples

			2* 2 = 2 +  2,                                      so a(1) =  2.
2* 4 = 3 +  5 = 5 +  3,                             so a(2) =  4.
2* 5 = 3 +  7 = 5 +  5 =  7 +  3,                   so a(3) =  5.
2* 8 = 3 + 13 = 5 + 11 = 11 +  5 = 13 + 3,          so a(4) =  8.
2*11 = 3 + 19 = 5 + 17 = 11 + 11 = 17 + 5 = 19 + 3, so a(5) = 11.
		

Crossrefs

Cf. A035026.

Programs

  • PARI
    nb(n) = sum(i=1, 2*n-1, isprime(i) && isprime(2*n-i));
    a(n) = {my(k=1); while (nb(k) != n, k++); k;} \\ Michel Marcus, Jan 31 2018

A010051 Characteristic function of primes: 1 if n is prime, else 0.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

The following sequences all have the same parity (with an extra zero term at the start of a(n)): a(n), A061007, A035026, A069754, A071574. - Jeremy Gardiner, Aug 09 2002
Hardy and Wright prove that the real number 0.011010100010... is irrational. See Nasehpour link. - Michel Marcus, Jun 21 2018
The spectral components (excluding the zero frequency) of the Fourier transform of the partial sequences {a(j)} with j=1..n and n an even number, exhibit a remarkable symmetry with respect to the central frequency component at position 1 + n/4. See the Fourier spectrum of the first 2^20 terms in Links, Comments in A289777, and Conjectures in A001223 of Sep 01 2019. It also appears that the symmetry grows with n. - Andres Cicuttin, Aug 23 2020

References

  • J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 3.
  • V. Brun, Über das Goldbachsche Gesetz und die Anzahl der Primzahlpaare, Arch. Mat. Natur. B, 34, no. 8, 1915.
  • G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, Oxford University Press, London, 1975.
  • Clifford A. Pickover, A Passion for Mathematics, Wiley, 2005; see p. 65.
  • Paulo Ribenboim, The Little Book of Bigger Primes, Springer-Verlag NY 2004. See p. 132.

Crossrefs

Cf. A051006 (constant 0.4146825... (base 10) = 0.01101010001010001010... (base 2)), A001221 (inverse Moebius transform), A143519, A156660, A156659, A156657, A059500, A053176, A059456, A072762.
First differences of A000720, so A000720 gives partial sums.
Column k=1 of A117278.
Characteristic function of A000040.
Cf. A008683.

Programs

  • Haskell
    import Data.List (unfoldr)
    a010051 :: Integer -> Int
    a010051 n = a010051_list !! (fromInteger n-1)
    a010051_list = unfoldr ch (1, a000040_list) where
       ch (i, ps'@(p:ps)) = Just (fromEnum (i == p),
                                  (i + 1, if i == p then ps else ps'))
    -- Reinhard Zumkeller, Apr 17 2012, Sep 15 2011
    
  • Magma
    s:=[]; for n in [1..100] do if IsPrime(n) then s:=Append(s,1); else s:=Append(s,0); end if; end for; s;
    
  • Magma
    [IsPrime(n) select 1 else 0: n in [1..100]];  // Bruno Berselli, Mar 02 2011
    
  • Maple
    A010051:= n -> if isprime(n) then 1 else 0 fi;
  • Mathematica
    Table[ If[ PrimeQ[n], 1, 0], {n, 105}] (* Robert G. Wilson v, Jan 15 2005 *)
    Table[Boole[PrimeQ[n]], {n, 105}] (* Alonso del Arte, Aug 09 2011 *)
    Table[PrimePi[n] - PrimePi[n-1], {n,50}] (* G. C. Greubel, Jan 05 2017 *)
  • PARI
    a(n)=isprime(n) \\ Charles R Greathouse IV, Apr 16 2011
    
  • Python
    from sympy import isprime
    def A010051(n): return int(isprime(n)) # Chai Wah Wu, Jan 20 2022

Formula

a(n) = floor(cos(Pi*((n-1)! + 1)/n)^2) for n >= 2. - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Nov 07 2002
Let M(n) be the n X n matrix m(i, j) = 0 if n divides ij + 1, m(i, j) = 1 otherwise; then for n > 0 a(n) = -det(M(n)). - Benoit Cloitre, Jan 17 2003
n >= 2, a(n) = floor(phi(n)/(n - 1)) = floor(A000010(n)/(n - 1)). - Benoit Cloitre, Apr 11 2003
a(n) = Sum_{d|gcd(n, A034386(n))} mu(d). [Brun]
a(m*n) = a(m)*0^(n - 1) + a(n)*0^(m - 1). - Reinhard Zumkeller, Nov 25 2004
a(n) = 1 if n has no divisors other than 1 and n, and 0 otherwise. - Jon Perry, Jul 02 2005
Dirichlet generating function: Sum_{n >= 1} a(n)/n^s = primezeta(s), where primezeta is the prime zeta function. - Franklin T. Adams-Watters, Sep 11 2005
a(n) = (n-1)!^2 mod n. - Franz Vrabec, Jun 24 2006
a(n) = A047886(n, 1). - Reinhard Zumkeller, Apr 15 2008
Equals A051731 (the inverse Möbius transform) * A143519. - Gary W. Adamson, Aug 22 2008
a(n) = A051731((n + 1)! + 1, n) from Wilson's theorem: n is prime if and only if (n + 1)! is congruent to -1 mod n. - N-E. Fahssi, Jan 20 2009, Jan 29 2009
a(n) = A166260/A001477. - Mats Granvik, Oct 10 2009
a(n) = 0^A070824, where 0^0=1. - Mats Granvik, Gary W. Adamson, Feb 21 2010
It appears that a(n) = (H(n)*H(n + 1)) mod n, where H(n) = n!*Sum_{k=1..n} 1/k = A000254(n). - Gary Detlefs, Sep 12 2010
Dirichlet generating function: log( Sum_{n >= 1} 1/(A112624(n)*n^s) ). - Mats Granvik, Apr 13 2011
a(n) = A100995(n) - sqrt(A100995(n)*A193056(n)). - Mats Granvik, Jul 15 2011
a(n) * (2 - n mod 4) = A151763(n). - Reinhard Zumkeller, Oct 06 2011
(n - 1)*a(n) = ( (2*n + 1)!! * Sum_{k=1..n}(1/(2*k + 1))) mod n, n > 2. - Gary Detlefs, Oct 07 2011
For n > 1, a(n) = floor(1/A001222(n)). - Enrique Pérez Herrero, Feb 23 2012
a(n) = mu(n) * Sum_{d|n} mu(d)*omega(d), where mu is A008683 and omega A001222 or A001221 indistinctly. - Enrique Pérez Herrero, Jun 06 2012
a(n) = A003418(n+1)/A003418(n) - A217863(n+1)/A217863(n) = A014963(n) - A072211(n). - Eric Desbiaux, Nov 25 2012
For n > 1, a(n) = floor(A014963(n)/n). - Eric Desbiaux, Jan 08 2013
a(n) = ((abs(n-2))! mod n) mod 2. - Timothy Hopper, May 25 2015
a(n) = abs(F(n)) - abs(F(n)-1/2) - abs(F(n)-1) + abs(f(n)-3/2), where F(n) = Sum_{m=2..n+1} (abs(1 - (n mod m)) - abs(1/2 - (n mod m)) + 1/2), n > 0. F(n) = 1 if n is prime, > 1 otherwise, except F(1) = 0. a(n) = 1 if F(n) = 1, 0 otherwise. - Timothy Hopper, Jun 16 2015
For n > 4, a(n) = (n-2)! mod n. - Thomas Ordowski, Jul 24 2016
From Ilya Gutkovskiy, Jul 24 2016: (Start)
G.f.: A(x) = Sum_{n>=1} x^A000040(n) = B(x)*(1 - x), where B(x) is the g.f. for A000720.
a(n) = floor(2/A000005(n)), for n>1. (End)
a(n) = pi(n) - pi(n-1) = A000720(n) - A000720(n-1), for n>=1. - G. C. Greubel, Jan 05 2017
Decimal expansion of Sum_{k>=1} (1/10)^prime(k) = 9 * Sum_{k>=1} pi(k)/10^(k+1), where pi(k) = A000720(k). - Amiram Eldar, Aug 11 2020
a(n) = 1 - ceiling((2/n) * Sum_{k=2..floor(sqrt(n))} floor(n/k)-floor((n-1)/k)), n>1. - Gary Detlefs, Sep 08 2023
a(n) = Sum_{d|n} mu(d)*omega(n/d), where mu = A008683 and omega = A001221. - Ridouane Oudra, Apr 12 2025
a(n) = 0 if (n^2 - 3*n + 2) * A000203(n) - 8 * A002127(n) > 0 else 1 (n>2, see Craig link). - Bill McEachen, Jul 04 2025

A045917 From Goldbach problem: number of decompositions of 2n into unordered sums of two primes.

Original entry on oeis.org

0, 1, 1, 1, 2, 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 2, 4, 4, 2, 3, 4, 3, 4, 5, 4, 3, 5, 3, 4, 6, 3, 5, 6, 2, 5, 6, 5, 5, 7, 4, 5, 8, 5, 4, 9, 4, 5, 7, 3, 6, 8, 5, 6, 8, 6, 7, 10, 6, 6, 12, 4, 5, 10, 3, 7, 9, 6, 5, 8, 7, 8, 11, 6, 5, 12, 4, 8, 11, 5, 8, 10, 5, 6, 13, 9, 6, 11, 7, 7, 14, 6, 8, 13, 5, 8, 11, 7, 9
Offset: 1

Views

Author

Keywords

Comments

Note that A002375 (which differs only at the n = 2 term) is the main entry for this sequence.
The graph of this sequence is called Goldbach's comet. - David W. Wilson, Mar 19 2012
This is the row length sequence of A182138, A184995 and A198292. - Jason Kimberley, Oct 03 2012
The Goldbach conjecture states that a(n) > 0 for n >= 2. - Wolfdieter Lang, May 14 2016
With the second Maple program, the command G(2n) yields all the unordered pairs of prime numbers having sum 2n; caveat: a pair {a,a} is listed as {a}. Example: G(26) yields {{13}, {3,23}, {7,19}}. The command G(100000) yields 810 pairs very fast. - Emeric Deutsch, Jan 03 2017
Conjecture: Let p denote any prime in any decomposition of 2n. 4 and 6 are the only numbers n such that 2n + p is prime for every p. - Ivan N. Ianakiev, Apr 06 2017
Conjecture: For all m >= 0, there exists at least one possible value of n such that a(n) = m. - Ahmad J. Masad, Jan 06 2018
The previous conjecture is related to the sequence A053033. - Ahmad J. Masad, Dec 09 2019
Conjecture: For each k >= 0, there exists a minimum sufficiently large number r that depends on k such that for each n >= r, a(n) > k. - Ahmad J. Masad, Jan 08 2020
Conjecture: If the previous conjecture is true, then for each m >= 0, the number of terms that are equal to (m+1) is larger than the number of terms that are equal to m. - Ahmad J. Masad, Jan 08 2020
Also, the number of equidistant prime pairs in Goldbach's Prime Triangle for integers n > 2. An equidistant prime pair is a pair of not necessarily different prime numbers (p1, p2) that have the same distance d >= 0 from an integer n, i.e., so that p1 = n - d and p2 = n + d. - Jörg Winkelmann, Mar 05 2025

References

  • Calvin C. Clawson, "Mathematical Mysteries, the beauty and magic of numbers," Perseus Books, Cambridge, MA, 1996, Chapter 12, pages 236-257.
  • H. Halberstam and H. E. Richert, 1974, "Sieve methods", Academic press, London, New York, San Francisco.

Crossrefs

Cf. A002375 (the main entry for this sequence (which differs only at the n=2 term)).
Cf. A023036 (first appearance of n), A000954 (last (assumed) appearance of n).

Programs

  • Haskell
    a045917 n = sum $ map (a010051 . (2 * n -)) $ takeWhile (<= n) a000040_list
    -- Reinhard Zumkeller, Sep 02 2013
    
  • Magma
    [#RestrictedPartitions(2*n,2,Set(PrimesInInterval(1,2*n))):n in [1..100]]; // Marius A. Burtea, Jan 23 2020
  • Maple
    A045917 := proc(n)
        local a,i ;
        a := 0 ;
        for i from 1 to n do
            if isprime(i) and isprime(2*n-i) then
                a := a+1 ;
            end if;
        end do:
        a ;
    end proc: # R. J. Mathar, Jul 01 2013
    # second Maple program:
    G := proc (n) local g, j: g := {}: for j from 2 to (1/2)*n do if isprime(j) and isprime(n-j) then g := `union`(g, {{n-j, j}}) end if end do: g end proc: seq(nops(G(2*n)), n = 1 .. 98); # Emeric Deutsch, Jan 03 2017
  • Mathematica
    f[n_] := Length[Select[2n - Prime[Range[PrimePi[n]]], PrimeQ]]; Table[ f[n], {n, 100}] (* Paul Abbott, Jan 11 2005 *)
    nn = 10^2; ps = Boole[PrimeQ[Range[1,2*nn,2]]]; Join[{0,1}, Table[Sum[ps[[i]] ps[[n-i+1]], {i, Ceiling[n/2]}], {n, 3, nn}]] (* T. D. Noe, Apr 13 2011 *)
  • PARI
    a(n)=my(s);forprime(p=2,n,s+=isprime(2*n-p));s \\ Charles R Greathouse IV, Mar 27 2012
    
  • Python
    from sympy import isprime
    def A045917(n):
        x = 0
        for i in range(2,n+1):
            if isprime(i) and isprime(2*n-i):
                x += 1
        return x # Chai Wah Wu, Feb 24 2015
    

Formula

From Halberstam and Richert: a(n) < (8+0(1))*c(n)*n/log(n)^2 where c(n) = Product_{p>2} (1 - 1/(p-1)^2)*Product_{p|n, p>2} (p-1)/(p-2). It is conjectured that the factor 8 can be replaced by 2. - Benoit Cloitre, May 16 2002
a(n) = ceiling(A035026(n) / 2) = (A035026(n) + A010051(n)) / 2.
a(n) = Sum_{i=2..n} floor(2/Omega(i*(2*n-i))). - Wesley Ivan Hurt, Jan 24 2013
a(n) = A224709(n) + (primepi(2n-2) - primepi(n-1)) + primepi(n) + 1 - n. - Anthony Browne, May 03 2016
a(n) = A224708(2n) - A224708(2n+1) + A010051(n). - Anthony Browne, Jun 26 2016
a(n) = Sum_{k=n*(n-1)/2+2..n*(n+1)/2} A064911(A105020(k-1)). - Wesley Ivan Hurt, Sep 11 2021
a(n) = omega(A362641(n)) = omega(A362640(n)). - Wesley Ivan Hurt, Apr 28 2023

A002372 Goldbach conjecture: number of decompositions of 2n into ordered sums of two odd primes.

Original entry on oeis.org

0, 0, 1, 2, 3, 2, 3, 4, 4, 4, 5, 6, 5, 4, 6, 4, 7, 8, 3, 6, 8, 6, 7, 10, 8, 6, 10, 6, 7, 12, 5, 10, 12, 4, 10, 12, 9, 10, 14, 8, 9, 16, 9, 8, 18, 8, 9, 14, 6, 12, 16, 10, 11, 16, 12, 14, 20, 12, 11, 24, 7, 10, 20, 6, 14, 18, 11, 10, 16, 14, 15, 22, 11, 10, 24, 8, 16, 22, 9, 16, 20, 10
Offset: 1

Views

Author

Keywords

Comments

The weak form of this conjecture was proved by Helfgott (see link below). - T. D. Noe, May 14 2013
Goldbach conjectured in 1742 that for n >= 3, this sequence never vanishes. This is still unproved.
Number of different primes occurring when 2n is expressed as p1+q1 = ... = pk+qk where pk,qk are odd primes with pk <= qk. For example when n=5: 10 = 3+7 = 5+5, we can see 3 different primes so a(5) = 3. - Naohiro Nomoto, Feb 24 2002
Comments from Tomás Oliveira e Silva to Number Theory List, Feb 05 2005: With the help of Siegfied "Zig" Herzog of PSU, I was able to verify the Goldbach conjecture up to 2e17. Let 2n=p+q, with p and q prime be a Goldbach partition of 2n. In a minimal Goldbach partition p is as small as possible. The largest p of a minimal Goldbach partition found was 8443 and is needed for 2n=121005022304007026. Furthermore, the largest prime gap found was 1220-1; it occurs after the prime 80873624627234849.
Comments from Tomás Oliveira e Silva to Number Theory List, Apr 26 2007: With the help of Siegfried "Zig" Herzog, the NCSA and others, I have just finished the verification of the Goldbach conjecture up to 1e18. This took about 320 years of CPU time, including a double-check of the results up to 1e17. As expected, no counterexample to the conjecture was found. As side results, the number of twin primes up to 1e18 was also computed, as was the number of primes in each of the residue classes modulo 120. Also, the number of occurrences of each (observed) prime gap was also recorded.
For n > 2 we have a(n) = 2*A002375(n)-1 if n is prime and a(n) = 2*A002375(n) if n is composite. - Emeric Deutsch, Jul 14 2004
For n > 2, a(n) = 2*A002375(n) - A010051(n). - Jason Kimberley, Aug 31 2011
a(n) = Sum_{p odd prime < 2*n} A010051(2*n - p). - Reinhard Zumkeller, Oct 19 2011
There is an interesting similarity with square numbers: The number of divisors of n is odd iff n is square (A000290). The number of decompositions of 2n into ordered sums of two primes (equaling the number of the unique primes in all such decompositions) is odd iff n is prime. - Ivan N. Ianakiev, Feb 28 2015

Examples

			2 has no such decompositions, so a(1) = 0.
Idem for 4, whence a(2) = 0.
6 = 3+3, so a(3) = 1.
8 = 3+5 = 5+3, so a(4) = 2.
10 = 5+5 = 3+7 = 7+3, so a(5) = 3.
12 = 5+7 = 7+5; so a(6) = 2, etc.
		

References

  • T. M. Apostol, Introduction to Analytic Number Theory, Springer-Verlag, 1976, page 9.
  • R. K. Guy, Unsolved problems in number theory, second edition, Springer-Verlag, 1994.
  • G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, 5th ed., Oxford Univ. Press, 1979, Section 2.8 (for Goldbach conjecture).
  • D. H. Lehmer, Guide to Tables in the Theory of Numbers. Bulletin No. 105, National Research Council, Washington, DC, 1941, pp. 79, 80.
  • N. Pipping, Neue Tafeln für das Goldbachsche Gesetz nebst Berichtigungen zu den Haussnerschen Tafeln, Finska Vetenskaps-Societeten, Comment. Physico Math. 4 (No. 4, 1927), pp. 1-27.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • M. L. Stein and P. R. Stein, Tables of the Number of Binary Decompositions of All Even Numbers Less Than 200,000 into Prime Numbers and Lucky Numbers. Report LA-3106, Los Alamos Scientific Laboratory of the University of California, Los Alamos, NM, Sep 1964.

Crossrefs

Essentially identical to A035026.

Programs

  • Haskell
    a002372 n = sum $ map (a010051 . (2*n -)) $ takeWhile (< 2*n) a065091_list
    -- Reinhard Zumkeller, Oct 19 2011
    
  • Magma
    A002372 := func; [A002372(n):n in[1..82]]; // Jason Kimberley, Sep 01 2011
    
  • Maple
    a:=proc(n) local c,k; c:=0: for k from 1 to n do if isprime(2*k+1)=true and isprime(2*n-2*k-1)=true then c:=c+1 else c:=c fi od end: seq(a(n),n=1..82); # Emeric Deutsch, Jul 14 2004
  • Mathematica
    For[lst={}; n=1, n<=100, n++, For[cnt=0; i=1, i<=2n-1, i++ If[OddQ[i]&&PrimeQ[i]&&PrimeQ[2n-i], cnt++ ]]; AppendTo[lst, cnt]]; lst
    (* second program: *)
    A002372[n_] := Module[{i = 0}, Do[If[PrimeQ[2 n - Prime@p], i++], {p, 2, PrimePi[2 n - 3]}]; i]; Array[A002372, 82] (* JungHwan Min, Aug 24 2016 *)
    i[n_] := If[PrimeQ[2 n - 1], 2 n - 1, 0]; A085090 = Array[i, 82];
    r[n_] := Table[A085090[[k]] + A085090[[n - k + 1]], {k, 1, n}];
    countzeros[l_List] := Sum[KroneckerDelta[0, k], {k, l}];
    Table[n - 2 countzeros[A085090[[1 ;; n]]] + countzeros[r[n]],
    {n, 1, 82}] (* Fred Daniel Kline, Aug 13 2018 *)
    countPrimes[n_] := Sum[KroneckerDelta[True, PrimeQ[2 m - 1],
    PrimeQ[2 (n - m + 1) - 1]], {m, 1, n}]; Array[countPrimes, 82] (* Fred Daniel Kline, Oct 07 2018 *)
  • PARI
    isop(n) = (n % 2) && isprime(n);
    a(n) = n*=2; sum(i=1, n-1, isop(i)*isop(n-i)); \\ Michel Marcus, Aug 22 2014 and May 28 2020
    
  • Python
    from sympy import isprime, primerange
    def a(n): return sum([1 for p in primerange(3, 2*n-2) if isprime(2*n-p)])
    print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Apr 23 2017

Formula

a(n) = A010051(n) + 2*A061357(n), n > 2. - R. J. Mathar, Aug 19 2013

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Jun 13 2002
Edited by M. F. Hasler, May 03 2019

A020482 Greatest p with p, q both prime, p+q = 2n.

Original entry on oeis.org

2, 3, 5, 7, 7, 11, 13, 13, 17, 19, 19, 23, 23, 23, 29, 31, 31, 31, 37, 37, 41, 43, 43, 47, 47, 47, 53, 53, 53, 59, 61, 61, 61, 67, 67, 71, 73, 73, 73, 79, 79, 83, 83, 83, 89, 89, 89, 79, 97, 97, 101, 103, 103, 107, 109, 109, 113, 113, 113, 109, 113, 113, 109, 127, 127, 131, 131
Offset: 2

Views

Author

Keywords

Comments

a(n) = A171637(n,A035026(n)). - Reinhard Zumkeller, Mar 03 2014

Crossrefs

Programs

  • Haskell
    a020482 = last . a171637_row  -- Reinhard Zumkeller, Mar 03 2014
    
  • Mathematica
    a[n_] := {p, q} /. {ToRules @ Reduce[p+q == 2*n, {p, q}, Primes]} // Max; Table[a[n], {n, 2, 100}] (* Jean-François Alcover, Dec 19 2013 *)
    Table[Max[Flatten[Select[IntegerPartitions[2n,{2}],AllTrue[#,PrimeQ]&]]],{n,2,70}] (* Harvey P. Dale, Sep 04 2024 *)
  • PARI
    a(n)=forprime(q=2,n,if(isprime(2*n-q), return(2*n-q))) \\ Charles R Greathouse IV, Apr 28 2015
    
  • Python
    from sympy import primerange, isprime
    def A020482(n): return next(m for p in primerange(2*n) if isprime(m:=(n<<1)-p)) # Chai Wah Wu, Nov 19 2024

A047160 For n >= 2, a(n) = smallest number m >= 0 such that n-m and n+m are both primes, or -1 if no such m exists.

Original entry on oeis.org

0, 0, 1, 0, 1, 0, 3, 2, 3, 0, 1, 0, 3, 2, 3, 0, 1, 0, 3, 2, 9, 0, 5, 6, 3, 4, 9, 0, 1, 0, 9, 4, 3, 6, 5, 0, 9, 2, 3, 0, 1, 0, 3, 2, 15, 0, 5, 12, 3, 8, 9, 0, 7, 12, 3, 4, 15, 0, 1, 0, 9, 4, 3, 6, 5, 0, 15, 2, 3, 0, 1, 0, 15, 4, 3, 6, 5, 0, 9, 2, 15, 0, 5, 12, 3, 14, 9, 0, 7, 12, 9, 4, 15, 6, 7, 0, 9, 2, 3
Offset: 2

Views

Author

Keywords

Comments

I have confirmed there are no -1 entries through integers to 4.29*10^9 using PARI. - Bill McEachen, Jul 07 2008
From Daniel Forgues, Jul 02 2009: (Start)
Goldbach's Conjecture: for all n >= 2, there are primes (distinct or not) p and q s.t. p+q = 2n. The primes p and q must be equidistant (distance m >= 0) from n: p = n-m and q = n+m, hence p+q = (n-m)+(n+m) = 2n.
Equivalent to Goldbach's Conjecture: for all n >= 2, there are primes p and q equidistant (distance >= 0) from n, where p and q are n when n is prime.
If this conjecture is true, then a(n) will never be set to -1.
Twin Primes Conjecture: there is an infinity of twin primes.
If this conjecture is true, then a(n) will be 1 infinitely often (for which each twin primes pair is (n-1, n+1)).
Since there is an infinity of primes, a(n) = 0 infinitely often (for which n is prime).
(End)
If n is composite, then n and a(n) are coprime, because otherwise n + a(n) would be composite. - Jason Kimberley, Sep 03 2011
From Jianglin Luo, Sep 22 2023: (Start)
a(n) < primepi(n)+sigma(n,0);
a(n) < primepi(primepi(n)+n);
a(n) < primepi(n), for n>344;
a(n) = o(primepi(n)), as n->+oo. (End)
If -1 < a(n) < n-3, then a(n) is divisible by 3 if and only if n is not divisible by 3, and odd if and only if n is even. - Robert Israel, Oct 05 2023

Examples

			16-3=13 and 16+3=19 are primes, so a(16)=3.
		

Crossrefs

Programs

  • Haskell
    a047160 n = if null ms then -1 else head ms
                where ms = [m | m <- [0 .. n - 1],
                                a010051' (n - m) == 1, a010051' (n + m) == 1]
    -- Reinhard Zumkeller, Aug 10 2014
    
  • Magma
    A047160:=func;[A047160(n):n in[2..100]]; // Jason Kimberley, Sep 02 2011
    
  • Mathematica
    Table[k = 0; While[k < n && (! PrimeQ[n - k] || ! PrimeQ[n + k]), k++]; If[k == n, -1, k], {n, 2, 100}]
    smm[n_]:=Module[{m=0},While[AnyTrue[n+{m,-m},CompositeQ],m++];m]; Array[smm,100,2] (* Harvey P. Dale, Nov 16 2024 *)
  • PARI
    a(n)=forprime(p=n,2*n, if(isprime(2*n-p), return(p-n))); -1 \\ Charles R Greathouse IV, Jun 23 2017
  • UBASIC
    10 N=2// 20 M=0// 30 if and{prmdiv(N-M)=N-M,prmdiv(N+M)=N+M} then print M;:goto 50// 40 inc M:goto 30// 50 inc N: if N>130 then stop// 60 goto 20
    

Formula

a(n) = n - A112823(n).
a(n) = A082467(n) * A005171(n), for n > 3. - Jason Kimberley, Jun 25 2012

Extensions

More terms from Patrick De Geest, May 15 1999
Deleted a comment. - T. D. Noe, Jan 22 2009
Comment corrected and definition edited by Daniel Forgues, Jul 08 2009

A171637 Triangle read by rows in which row n lists the distinct primes of the distinct decompositions of 2n into unordered sums of two primes.

Original entry on oeis.org

2, 3, 3, 5, 3, 5, 7, 5, 7, 3, 7, 11, 3, 5, 11, 13, 5, 7, 11, 13, 3, 7, 13, 17, 3, 5, 11, 17, 19, 5, 7, 11, 13, 17, 19, 3, 7, 13, 19, 23, 5, 11, 17, 23, 7, 11, 13, 17, 19, 23, 3, 13, 19, 29, 3, 5, 11, 17, 23, 29, 31, 5, 7, 13, 17, 19, 23, 29, 31, 7, 19, 31, 3, 11, 17, 23, 29, 37, 5, 11
Offset: 2

Views

Author

Juri-Stepan Gerasimov, Dec 13 2009

Keywords

Comments

Each entry of the n-th row is a prime p from the n-th row of A002260 such that 2n-p is also prime. If A002260 is read as the antidiagonals of a square array, this sequence can be read as an irregular square array (see example below). The n-th row has length A035026(n). This sequence is the nonzero subsequence of A154725. - Jason Kimberley, Jul 08 2012

Examples

			a(2)=2 because for row 2: 2*2=2+2; a(3)=3 because for row 3: 2*3=3+3; a(4)=3 and a(5)=5 because for row 4: 2*4=3+5; a(6)=3, a(7)=5 and a(8)=7 because for row 5: 2*5=3+7=5+5.
The table starts:
2;
3;
3,5;
3,5,7;
5,7;
3,7,11;
3,5,11,13;
5,7,11,13;
3,7,13,17;
3,5,11,17,19;
5,7,11,13,17,19;
3,7,13,19,23;
5,11,17,23;
7,11,13,17,19,23;
3,13,19,29;
3,5,11,17,23,29,31;
As an irregular square array [_Jason Kimberley_, Jul 08 2012]:
3 . 3 . 3 . . . 3 . 3 . . . 3 . 3
. . . . . . . . . . . . . . . .
5 . 5 . 5 . . . 5 . 5 . . . 5
. . . . . . . . . . . . . .
7 . 7 . 7 . . . 7 . 7 . .
. . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . .
11. 11. 11. . . 11
. . . . . . . .
13. 13. 13. .
. . . . . .
. . . . .
. . . .
17. 17
. .
19
		

Crossrefs

Related triangles: A154720, A154721, A154722, A154723, A154724, A154725, A154726, A154727, A184995. - Jason Kimberley, Sep 03 2011
Cf. A020481 (left edge), A020482 (right edge), A238778 (row sums), A238711 (row products), A000040, A010051.

Programs

  • Haskell
    a171637 n k = a171637_tabf !! (n-2) !! (k-1)
    a171637_tabf = map a171637_row [2..]
    a171637_row n = reverse $ filter ((== 1) . a010051) $
       map (2 * n -) $ takeWhile (<= 2 * n) a000040_list
    -- Reinhard Zumkeller, Mar 03 2014
  • Mathematica
    Table[ps = Prime[Range[PrimePi[2*n]]]; Select[ps, MemberQ[ps, 2*n - #] &], {n, 2, 50}] (* T. D. Noe, Jan 27 2012 *)

Extensions

Keyword:tabl replaced by tabf, arbitrarily defined a(1) removed and entries checked by R. J. Mathar, May 22 2010
Definition clarified by N. J. A. Sloane, May 23 2010

A071574 If n = k-th prime, a(n) = 2*a(k) + 1; if n = k-th nonprime, a(n) = 2*a(k).

Original entry on oeis.org

0, 1, 3, 2, 7, 6, 5, 4, 14, 12, 15, 10, 13, 8, 28, 24, 11, 30, 9, 20, 26, 16, 29, 56, 48, 22, 60, 18, 25, 40, 31, 52, 32, 58, 112, 96, 21, 44, 120, 36, 27, 50, 17, 80, 62, 104, 57, 64, 116, 224, 192, 42, 49, 88, 240, 72, 54, 100, 23, 34, 61, 160, 124, 208, 114, 128, 19
Offset: 1

Views

Author

Christopher Eltschka (celtschk(AT)web.de), May 31 2002

Keywords

Comments

The recursion start is implicit in the rule, since the rule demands that a(1)=2*a(1). All other terms are defined through terms for smaller indices until a(1) is reached.
a(n) is a bijective mapping from the positive integers to the nonnegative integers. Given the value of a(n), you can get back to n using the following algorithm:
Start with an initial value of k=1 and write a(n) in binary representation. Then for each bit, starting with the most significant one, do the following: - if the bit is 1, replace k by the k-th prime - if the bit is 0, replace k by the k-th nonprime. After you processed the last (i.e. least significant) bit of a(n), you've got n=k.
Example: From a(n) = 12 = 1100_2, you get 1->2->3=>6=>10; a(10)=12. Here each "->" is a step due to binary digit 1; each "=>" is a step due to binary digit 0.
The following sequences all appear to have the same parity (with an extra zero term at the start of A010051): A010051, A061007, A035026, A069754, A071574. - Jeremy Gardiner, Aug 09 2002. (At least with this sequence the identity a(n) = A010051(n) mod 2 is obvious, because each prime is mapped to an odd number and each composite to an even number. - Antti Karttunen, Apr 04 2015)
For n > 1: a(n) = 2 * a(if i > 0 then i else A066246(n) + 1) + A057427(i) with i = A049084(n). - Reinhard Zumkeller, Feb 12 2014
A237739(a(n)) = n; a(A237739(n)) = n. - Reinhard Zumkeller, Apr 30 2014

Examples

			1 is the 1st nonprime, so a(1) = 2*a(1), therefore a(1) = 0.
2 is the 1st prime, so a(2) = 2*a(1)+1 = 2*0+1 = 1.
4 is the 2nd nonprime, so a(4) = 2*a(2) = 2*1 = 2.
		

Crossrefs

Inverse: A237739.
Compare also to the permutation A246377.
Same parity: A010051, A061007, A035026, A069754.

Programs

  • Haskell
    a071574 1 = 0
    a071574 n = 2 * a071574 (if j > 0 then j + 1 else a049084 n) + 1 - signum j
                where j = a066246 n
    -- Reinhard Zumkeller, Feb 12 2014
    
  • Mathematica
    a[1]=0; a[n_]:=If[PrimeQ[n],2*a[PrimePi[n]]+1,2*a[n-PrimePi[n]]];Table[a[n],{n,100}]
  • PARI
    first(n) = my(res = vector(n), p); for(x=2, n, p=isprime(x); res[x]=2*res[x*!p-(-1)^p*primepi(x)]+p); res \\ Iain Fox, Oct 19 2018
  • Scheme
    ;; With memoizing definec-macro.
    (definec (A071574 n) (cond ((= 1 n) 0) ((= 1 (A010051 n)) (+ 1 (* 2 (A071574 (A000720 n))))) (else (* 2 (A071574 (+ 1 (A065855 n)))))))
    ;; Antti Karttunen, Apr 04 2015
    

Formula

a(1) = 0, and for n > 1, if A010051(n) = 1 [when n is a prime], a(n) = 1 + 2*a(A000720(n)), otherwise a(n) = 2*a(1 + A065855(n)). - Antti Karttunen, Apr 04 2015

Extensions

Mathematica program completed by Harvey P. Dale, Nov 28 2024

A061007 a(n) = -(n-1)! mod n.

Original entry on oeis.org

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

Views

Author

Henry Bottomley, Apr 12 2001

Keywords

Comments

The following sequences all appear to have the same parity (with an extra zero term at the start of A010051): A010051, A061007, A035026, A069754, A071574. - Jeremy Gardiner, Aug 09 2002
In particular, this is identical to the isprime function A010051 except for a(4) = 2 instead of 0. This is equivalent to Wilson's theorem, (n-1)! == -1 (mod n) iff n is prime. If n = p*q with p, q > 1, then p, q < n-1 and (n-1)! will contain the two factors p and q, unless p = q = 2 (if p = q > 2 then also 2p < n-1, so there are indeed two factors p in (n-1)!), whence (n-1)! == 0 (mod n). - M. F. Hasler, Jul 19 2024

Examples

			a(4) = 2 since -(4 - 1)! = -6 = 2 mod 4.
a(5) = 1 since -(5 - 1)! = -24 = 1 mod 5.
a(6) = 0 since -(6 - 1)! = -120 = 0 mod 6.
		

Crossrefs

Positive for all but the first term of A046022.
Cf. A000040 (the primes), A000142, A010051 (isprime function), A055976, A061006, A061008, A061009.

Programs

Formula

a(4) = 2, a(p) = 1 for p prime, a(n) = 0 otherwise. Apart from n = 4, a(n) = A010051(n) = A061006(n)/(n-1).

A069754 Counts transitions between prime and nonprime to reach the number n.

Original entry on oeis.org

0, 1, 1, 2, 3, 4, 5, 6, 6, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 14, 14, 14, 15, 16, 16, 16, 16, 16, 17, 18, 19, 20, 20, 20, 20, 20, 21, 22, 22, 22, 23, 24, 25, 26, 26, 26, 27, 28, 28, 28, 28, 28, 29, 30, 30, 30, 30, 30, 31, 32, 33, 34, 34, 34, 34, 34, 35, 36, 36, 36, 37, 38, 39
Offset: 1

Views

Author

T. D. Noe, May 02 2002

Keywords

Comments

The following sequences all appear to have the same parity (with an extra zero term at the start of A010051): A010051, A061007, A035026, A069754, A071574. - Jeremy Gardiner, Aug 09 2002

Examples

			a(6) = 4 because there are 4 transitions: 1 to 2, 3 to 4, 4 to 5 and 5 to 6.
		

Crossrefs

Cf. A000720 (pi).
Cf. A211005 (run lengths).
Same parity: A010051, A061007, A035026, A071574.

Programs

  • Haskell
    a069754 1 = 0
    a069754 2 = 1
    a069754 n = 2 * a000720 n - 2 - (toInteger $ a010051 $ toInteger n)
    -- Reinhard Zumkeller, Dec 04 2012
  • Mathematica
    For[lst={0}; trans=0; n=2, n<100, n++, If[PrimeQ[n]!=PrimeQ[n-1], trans++ ]; AppendTo[lst, trans]]; lst
    (* Second program: *)
    pts[n_]:=Module[{c=2PrimePi[n]},If[PrimeQ[n],c-3,c-2]]; Join[{0,1},Array[ pts,80,3]] (* Harvey P. Dale, Nov 12 2011 *)
    Accumulate[If[Sort[PrimeQ[#]]=={False,True},1,0]&/@Partition[ Range[ 0,80],2,1]] (* Harvey P. Dale, May 06 2013 *)

Formula

When n is prime, a(n) = 2*pi(n) - 3. When n is composite, a(n) = 2*pi(n) - 2. pi(n) is the prime counting function A000720.
For n > 2: a(n) = 2*A000720(n) - 2 - A010051(n). - Reinhard Zumkeller, Dec 04 2012
Showing 1-10 of 18 results. Next