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-9 of 9 results.

A031131 Difference between n-th prime and (n+2)-nd prime.

Original entry on oeis.org

3, 4, 6, 6, 6, 6, 6, 10, 8, 8, 10, 6, 6, 10, 12, 8, 8, 10, 6, 8, 10, 10, 14, 12, 6, 6, 6, 6, 18, 18, 10, 8, 12, 12, 8, 12, 10, 10, 12, 8, 12, 12, 6, 6, 14, 24, 16, 6, 6, 10, 8, 12, 16, 12, 12, 8, 8, 10, 6, 12, 24, 18, 6, 6, 18, 20, 16, 12, 6, 10, 14, 14, 12, 10, 10, 14, 12, 12, 18, 12, 12, 12
Offset: 1

Views

Author

Keywords

Comments

Distance between the pair of primes adjacent to the (n+1)-st prime. - Lekraj Beedassy, Oct 01 2004 [Typo corrected by Zak Seidov, Feb 22 2009]
A031131(A261525(n)) = 2*n and A031131(m) != 2*n for m < A261525(n). - Reinhard Zumkeller, Aug 23 2015
The Polymath project 8b proved that a(n) <= 395106 infinitely often (their published paper contains the slightly weaker bound a(n) <= 398130 infinitely often). - Charles R Greathouse IV, Jul 22 2016

Examples

			a(10)=8 because the 10th prime=29 is followed by primes 31 and 37, and 37 - 29 = 8.
		

Crossrefs

Sum of consecutive terms of A001223.
Cf. A075527 (allowing 1 to be prime).
First differences of A001043.

Programs

  • Haskell
    a031131 n = a031131_list !! (n-1)
    a031131_list = zipWith (-) (drop 2 a000040_list) a000040_list
    -- Reinhard Zumkeller, Dec 19 2013
  • Magma
    [NthPrime(n+2)-NthPrime(n): n in [1..100] ]; // Vincenzo Librandi, Apr 11 2011
    
  • Maple
    P:= select(isprime, [2,seq(2*i+1,i=1..1000)]):
    P[3..-1] - P[1..-3]; # Robert Israel, Jan 25 2015
  • Mathematica
    Differences[lst_]:=Drop[lst,2]-Drop[lst,-2]; Differences[Prime[Range[123]]] (* Vladimir Joseph Stephan Orlovsky, Aug 13 2009 *)
    Map[#3 - #1 & @@ # &, Partition[Prime@ Range[84], 3, 1]] (* Michael De Vlieger, Dec 17 2017 *)
  • MuPAD
    ithprime(i+2)-ithprime(i) $ i = 1..65 // Zerinvary Lajos, Feb 26 2007
    
  • PARI
    a(n)=my(p=prime(n));nextprime(nextprime(p+1)+1)-p \\ Charles R Greathouse IV, Jul 01 2013
    
  • Sage
    BB = primes_first_n(67)
    L = []
    for i in range(65):
        L.append(BB[2+i]-BB[i])
    L
    # Zerinvary Lajos, May 14 2007
    

Formula

a(n) = A001223(n) + A001223(n-1). - Lior Manor, Jan 19 2005
a(n) = A000040(n+2) - A000040(n).
a(n) = 2*A052288(n-1) for n>1. - Hugo Pfoertner, Apr 16 2025

Extensions

Corrected by T. D. Noe, Sep 11 2008
Edited by N. J. A. Sloane, Sep 18 2008, at the suggestion of T. D. Noe

A054643 Primes prime(n) such that prime(n) + prime(n+1) + prime(n+2) == 0 (mod 3).

Original entry on oeis.org

3, 47, 151, 167, 199, 251, 257, 367, 503, 523, 557, 587, 601, 647, 727, 941, 971, 991, 1063, 1097, 1117, 1181, 1217, 1231, 1361, 1453, 1493, 1499, 1531, 1741, 1747, 1753, 1759, 1889, 1901, 1907, 2063, 2161, 2281, 2393, 2399, 2411, 2441, 2671, 2897, 2957
Offset: 1

Views

Author

Labos Elemer, May 15 2000

Keywords

Comments

The 2 differences of these 3 primes should be congruent of 6, except the first prime 3, for which 3 + 5 + 7 = 15 holds. Sequences like A047948, A052198 etc. are subsequences here.

Examples

			For prime(242) = 1531, the sum is 4623, the mean is 1541 and the successive differences are 6a=12 or 6b=6 resp.
		

Crossrefs

A122535 is a subsequence.
Cf. A075541 (for their indices).

Programs

  • Mathematica
    Select[Partition[Prime@ Range@ 430, 3, 1], Divisible[Total@ #, 3] &][[All, 1]] (* Michael De Vlieger, Jun 29 2017 *)

A162203 The mountain path of the primes (see comment lines for definition).

Original entry on oeis.org

2, 2, 2, 3, 1, -1, 1, 3, 1, -1, 1, 3, 1, -3, 1, 4, 1, -2, 1, 5, 1, -1, 1, 3, 1, -3, 1, 6, 1, -2, 1, 4, 1, -3, 1, 3, 1, -2, 1, 5, 1, -3, 1, 7, 1, -4, 1, 3, 1, -1, 1, 3, 1, -1, 1, 9, 1, -7, 1, 5, 1, -2, 1, 6, 1, -4, 1, 4, 1, -4, 1, 5, 1, -3, 1, 6, 1, -2, 1, 6
Offset: 1

Views

Author

Omar E. Pol, Jun 27 2009

Keywords

Comments

On the infinite square grid we draw an infinite straight line from the point (1,0) in direction (2,1).
We start at stage 1 from the point (0,0) drawing an edge ((0,0),(2,0)) in a horizontal direction.
At stage 2 we draw an edge ((2,0),(2,2)) in a vertical direction. We can see that the straight line intercepts at the number 3 (the first odd prime).
At stage 3 we draw an edge ((2,2),(4,2)) in a horizontal direction. We can see that the straight line intercepts at the number 5 (the second odd prime).
And so on (see illustrations).
The absolute value of a(n) is equal to the length of the n-th edge of a path, or infinite square polyedge, such that the mentioned straight line intercepts, on the path, at the number 1 and the odd primes. In other words, the straight line intercepts the odd noncomposite numbers (A006005).
The position of the x-th odd noncomposite number A006005(x) is represented by the point P(x,x-1).
So the position of the first prime number is represented by the point P(2,0) and position of the x-th prime A000040(x), for x>1, is represented by the point P(x,x-1); for example, 31, the 11th prime, is represented by the point P(11,10).
See also A162200, A162201 and A162202 for more information.

Examples

			Array begins:
=====
X..Y
=====
2, 2;
2, 3;
1,-1;
1, 3;
1,-1;
1, 3;
1,-3;
1, 4;
1,-2;
1, 5;
		

Crossrefs

Programs

  • PARI
    \\ (After Nathaniel Johnston_'s formula):
    A052288(n) = ((prime(n+3) - prime(n+1))/2);
    A162203(n) = if(n<=3, 2, if(n%2, 1, 1+((-1)^(n/2)*(A052288(n/2)-1)))); \\ Antti Karttunen, Mar 02 2023

Formula

From Nathaniel Johnston, May 10 2011: (Start)
a(2n+1) = 1 for n >= 2.
a(2n) = (-1)^n*(A162341(n+2) - 1) = (-1)^n*(A052288(n) - 1) + 1 for n >= 2. (End)

Extensions

Edited by Omar E. Pol, Jul 02 2009
More terms from Nathaniel Johnston, May 10 2011

A162200 Number on the positive y axis of the n-th horizontal component in the graph of the "mountain path" function for prime numbers.

Original entry on oeis.org

0, 0, 2, 2, 5, 4, 7, 6, 9, 6, 10, 8, 13, 12, 15, 12, 18, 16, 20, 17, 20, 18, 23, 20, 27, 23, 26, 25, 28, 27, 36, 29, 34, 32, 38, 34, 38, 34, 39, 36, 42, 40, 46, 42, 45, 44, 51, 41, 49, 48, 51, 48, 52, 48, 56, 52, 58, 56, 60, 57, 60, 56, 68, 61, 64, 63, 72, 64, 72, 68, 71, 68, 75
Offset: 1

Views

Author

Omar E. Pol, Jun 28 2009

Keywords

Comments

Note that the n-th horizontal component is an edge with length equal to 1 (see the link: Graph of the mountain path function).
See A162201 for the first differences.

Crossrefs

Programs

Extensions

Edited by Omar E. Pol, Jul 02 2009
More terms from R. J. Mathar, Jul 15 2009

A162201 First differences of A162200.

Original entry on oeis.org

0, 2, 0, 3, -1, 3, -1, 3, -3, 4, -2, 5, -1, 3, -3, 6, -2, 4, -3, 3, -2, 5, -3, 7, -4, 3, -1, 3, -1, 9, -7, 5, -2, 6, -4, 4, -4, 5, -3, 6, -2, 6, -4, 3, -1, 7, -10, 8, -1, 3, -3, 4, -4, 8, -4, 6, -2, 4, -3, 3, -4, 12, -7, 3, -1, 9, -8, 8, -4, 3, -3, 7, -5, 6, -3, 5, -5, 6, -4, 9, -4, 6, -4, 4, -3
Offset: 1

Views

Author

Omar E. Pol, Jun 28 2009

Keywords

Comments

The absolute value of a(n) is also the length of the n-th vertical edge in the graph of the "mountain path" function for prime numbers.
See A162200 for the length of the n-th horizontal component.

Crossrefs

Programs

Formula

From R. J. Mathar, Jul 15 2009: (Start)
a(n) = A052288(n-1) if n >= 2, n even.
a(n) = 2 - A052288(n-1) if n >= 3, n odd. (End)

Extensions

Edited by Omar E. Pol, Jul 02 2009
More terms from R. J. Mathar, Jul 15 2009

A162341 a(n) = number of grid points P(x,y) that are covered by a polyedge as the graph of the "mountain path" function for prime numbers, where x=n and y=0..oo.

Original entry on oeis.org

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

Views

Author

Omar E. Pol, Jul 01 2009

Keywords

Comments

Se also A162340.

Crossrefs

Formula

a(n) = A052288(n-2) + (-1)^n for n>=3. [From Nathaniel Johnston, Nov 06 2010]

Extensions

Edited by Omar E. Pol, Jul 05 2009
More terms from Nathaniel Johnston, Nov 06 2010

A162345 Length of n-th edge in the graph of the zig-zag function for prime numbers.

Original entry on oeis.org

2, 2, 2, 3, 3, 3, 3, 3, 5, 4, 4, 5, 3, 3, 5, 6, 4, 4, 5, 3, 4, 5, 5, 7, 6, 3, 3, 3, 3, 9, 9, 5, 4, 6, 6, 4, 6, 5, 5, 6, 4, 6, 6, 3, 3, 7, 12, 8, 3, 3, 5, 4, 6, 8, 6, 6, 4, 4, 5, 3, 6, 12, 9, 3, 3, 9, 10, 8, 6, 3, 5, 7, 7, 6, 5, 5, 7, 6, 6, 9, 6, 6, 6, 4, 5, 5
Offset: 1

Views

Author

Omar E. Pol, Jul 04 2009

Keywords

Comments

Also, first differences of A162800.
Also {2, 2, } together with the numbers A052288.
Note that the graph of the zig-zag function for prime numbers is similar to the graph of the mountain path function for prime numbers but with exactly a vertex between consecutive odd noncomposite numbers (A006005).
This is the same as A115061 if n>1 (and also essentially equal to A052288). Proof: Because this is the first differences of A162800, which is {0,2} together with A024675, this sequence (for n>=3) is given by a(n) = (prime(n+1) - prime(n-1))/2. Similarly, because half the numbers between prime(n-1) and prime(n+1) are closer to prime(n) than any other prime, A115061(n) = (prime(n+1) - prime(n-1))/2 for n>=3 as well. - Nathaniel Johnston, Jun 25 2011

Examples

			Array begins:
=====
x, y
=====
2, 2;
2, 3;
3, 3;
3, 3;
5, 4;
		

Crossrefs

Programs

  • Magma
    [2,2] cat[(NthPrime(n+1)-NthPrime(n-1))/2: n in [3..80]]; // Vincenzo Librandi, Dec 19 2016
  • Maple
    A162345 := proc(n) if(n<=2)then return 2: fi: return (ithprime(n+1) - ithprime(n-1))/2: end: seq(A162345(n),n=1..100); # Nathaniel Johnston, Jun 25 2011
  • Mathematica
    Join[{2, 2}, Table[(Prime[n+1] - Prime[n-1])/2, {n, 3, 100}]] (* Vincenzo Librandi, Dec 19 2016 *)

Formula

a(n) = (prime(n+1) - prime(n-1))/2 for n>=3. - Nathaniel Johnston, Jun 25 2011

Extensions

Edited by Omar E. Pol, Jul 16 2009

A115061 a(n) is the number of occurrences of the n-th prime number in A051697.

Original entry on oeis.org

3, 2, 2, 3, 3, 3, 3, 3, 5, 4, 4, 5, 3, 3, 5, 6, 4, 4, 5, 3, 4, 5, 5, 7, 6, 3, 3, 3, 3, 9, 9, 5, 4, 6, 6, 4, 6, 5, 5, 6, 4, 6, 6, 3, 3, 7, 12, 8, 3, 3, 5, 4, 6, 8, 6, 6, 4, 4, 5, 3, 6, 12, 9, 3, 3, 9, 10, 8, 6, 3, 5, 7, 7, 6, 5, 5, 7, 6, 6
Offset: 1

Views

Author

Lekraj Beedassy, Mar 01 2006

Keywords

Comments

Except for the second entry, the sequence also holds with respect to A077018.
a(n) equals A162345(n) for n>1 and equals A052288(n-2) for n>2. - Nathaniel Johnston, Jun 25 2011

Examples

			The 5th prime number, 11, appears three times in A051697. Therefore a(5) = 3.
		

Programs

  • Mathematica
    a = {3}; For[n = 2, n < 100, n++, c = 0; For[j = Prime[n - 1], j < Prime[n + 1], j++, If[j < Prime[n], If[Prime[n] - j < j - Prime[n - 1], c++ ], If[Not[Prime[n + 1] - j < j - Prime[n]], c++ ]]]; AppendTo[a, c]]; a

Formula

a(n) = (prime(n+1) - prime(n-1))/2 for n>=3. - Nathaniel Johnston, Jun 25 2011

Extensions

Edited and extended by Stefan Steinerberger, Oct 27 2007

A295705 The first of a pair of alternate primes the difference between which is twice a prime.

Original entry on oeis.org

3, 5, 7, 11, 13, 17, 19, 31, 37, 41, 43, 61, 67, 73, 79, 83, 97, 101, 103, 107, 127, 157, 163, 191, 193, 197, 223, 227, 229, 271, 277, 307, 311, 347, 349, 353, 359, 373, 379, 383, 433, 439, 443, 457, 461, 499, 509, 607, 613, 617, 619, 641, 643, 659, 673, 677, 719
Offset: 1

Views

Author

Geoffrey Marnell, Nov 25 2017

Keywords

Comments

Symbolically, the sequence is of p = prime(i) where q = (prime(i + 2) - prime(i))/2 and p and q are prime.
An examination of the first 10^9 primes (using Mathematica) shows that the largest value of q is 157 and it occurs just once: where p = 1907251013.
prime(k+1) where A052288(k) is prime. - Robert Israel, Dec 04 2017
Number of terms less than 10^k: 0, 3, 17, 72, 454, 3034, 22222, 174228, ... - Muniru A Asiru, Jan 24 2018

Examples

			{3, 7} represents a pair of alternate primes, their difference is 4 which is twice a prime (2). Likewise, {787, 809}, their difference being twice 11.
		

Crossrefs

Programs

  • GAP
    P:=Filtered([3..10^4], IsPrime);;
    B := List([1..Length(P)-2],i->(P[i+2]-P[i])/2);;
    o := [];; for i in [1..Length(B)] do if IsPrime(B[i]) then Add(o,P[i]); fi; od; o := A295705; # Muniru A Asiru, Jan 24 2018
  • Maple
    P:= select(isprime,[seq(i,i=3..10^4,2)]):
    P[select(t -> isprime((P[t+2]-P[t])/2), [$1..nops(P)-2])]; # Robert Israel, Dec 04 2017
  • Mathematica
    For[p = 1, p < 100000001, p++,
    a = Prime[p];
    b = Prime[p + 2];
    q = (b - a)/2;
    If[PrimeQ[q] == True, Print[a, " ", b, " ", q]];
    ] (* Marnell *)
    Select[Prime[Range[1000]], PrimeQ[(NextPrime[#, 2] - #)/2] &] (* Alonso del Arte, Nov 25 2017 *)
    searchMax = 200; primes = Prime[Range[searchMax + 2]]; halfAlternPrimeDiffs = Table[(primes[[n + 2]] - primes[[n]])/2, {n, searchMax}]; primes[[Select[Range[searchMax], PrimeQ[halfAlternPrimeDiffs[[#]]] &]]] (* Alonso del Arte, Nov 26 2017 *)
    Select[{#1, #2, (#2 - #1)/2} & @@ # & /@ Transpose@ {Take[#, Length@ # - 2], Drop[#, 2]} &@ Prime@ Range@ 130, PrimeQ@ Last@ # &][[All, 1]] (* Michael De Vlieger, Dec 04 2017 *)
    Select[Partition[Prime[Range[200]],3,1],PrimeQ[(#[[3]]-#[[1]])/2]&][[All,1]] (* Harvey P. Dale, Feb 20 2020 *)
  • PARI
    lista(nn) = {precp = 3; precq = 5; forprime(p=7, nn, if (isprime((p-precp)/2), print1(precp, ", ")); precp = precq; precq = p;);} \\ Michel Marcus, Jan 08 2018
    
Showing 1-9 of 9 results.