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.

A371201 a(n) = Sum_{k=prime(n)..prime(n+1)-1} k, with a(0) = 1.

Original entry on oeis.org

1, 2, 7, 11, 34, 23, 58, 35, 82, 153, 59, 201, 154, 83, 178, 297, 333, 119, 381, 274, 143, 453, 322, 513, 740, 394, 203, 418, 215, 442, 1673, 514, 801, 275, 1435, 299, 921, 957, 658, 1017, 1053, 359, 1855, 383, 778, 395, 2454, 2598, 898, 455, 922, 1413, 479, 2455, 1521, 1557, 1593
Offset: 0

Views

Author

Raul Prisacariu, Mar 15 2024

Keywords

Comments

The sequence can be obtained graphically using the following grid walk rules. From an origin the first movement iteration consists of moving 1 unit in any direction. The n-th movement iteration consists of moving in the same direction n units. If n is a prime number, the movement iteration consists of first changing the movement direction by 90 degrees and then moving n units in the new direction. If n is a nonprime number, the movement iteration consists of moving n units in the same direction as the previous movement iteration. The sequence is obtained by measuring the length of each 90-degree turn.
a(0) is the length of the grid segment before doing any 90-degree turns and a(1) is the length of the first 90-degree turn.

Examples

			a(0) = 1.
a(1) = 2.
a(2) = 3 + 4 = 7.
a(3) = 5 + 6 = 11.
a(4) = 7 + 8 + 9 + 10 = 34.
a(5) = 11 + 12 = 23.
a(6) = 13 + 14 + 15 + 16 = 58.
a(7) = 17 + 18 = 35.
The natural numbers are summed in groups where each prime begins a new group,
  primes     v   v       v       v
         1   2   3   4   5   6   7   8   9  10  ...
        \-/ \-/ \-----/ \-----/ \-------------/
  a(n) = 1   2     7       11          34
    n  = 0   1     2       3           4
		

Crossrefs

Cf. A008837 (partial sums).

Programs

  • Maple
    ithprime(0):=1:
    a:= n-> ((j, k)-> (k-1+j)*(k-j)/2)(map(ithprime, [n, n+1])[]):
    seq(a(n), n=0..56);  # Alois P. Heinz, Mar 16 2024
  • Mathematica
    Join[{1},Table[Prime[n]+(Prime[n+1]+Prime[n])*(Prime[n+1]-Prime[n]-1)/2,{n,56}]] (* James C. McMahon, Apr 20 2024 *)
  • PARI
    first(n) = {
    	my(res = primes(n), t = 0);
    	for(i = 1, n,
    		res[i] = binomial(res[i],2) - t;
    		t+=res[i];
    	);
    	res	
    } \\ David A. Corneth, Mar 16 2024
    
  • Python
    from sympy import nextprime, prime
    def A371201(n):
        if n == 0: return 1
        q = nextprime(p:=prime(n))
        return (q-p)*(p+q-1)>>1 # Chai Wah Wu, Jun 01 2024

Formula

For n > 0, a(n) = A138383(n) - (prime(n+1) - prime(n)).
a(n) = binomial(prime(n+1), 2) - Sum_{k=0..n-1} a(k). - David A. Corneth, Mar 15 2024
a(n) = prime(n) + A054265(n), for n >= 1. - Michel Marcus, Mar 15 2024
a(n) = (prime(n+1)-prime(n))*(prime(n+1)+prime(n)-1)/2 for n>=1. - Chai Wah Wu, Jun 01 2024

Extensions

More terms from Michel Marcus, Mar 15 2024