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.

This page as a plain text file.
%I A371201 #46 Jul 27 2025 17:46:27
%S A371201 1,2,7,11,34,23,58,35,82,153,59,201,154,83,178,297,333,119,381,274,
%T A371201 143,453,322,513,740,394,203,418,215,442,1673,514,801,275,1435,299,
%U A371201 921,957,658,1017,1053,359,1855,383,778,395,2454,2598,898,455,922,1413,479,2455,1521,1557,1593
%N A371201 a(n) = Sum_{k=prime(n)..prime(n+1)-1} k, with a(0) = 1.
%C A371201 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.
%C A371201 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.
%H A371201 Alois P. Heinz, <a href="/A371201/b371201.txt">Table of n, a(n) for n = 0..10000</a>
%F A371201 For n > 0, a(n) = A138383(n) - (prime(n+1) - prime(n)).
%F A371201 a(n) = binomial(prime(n+1), 2) - Sum_{k=0..n-1} a(k). - _David A. Corneth_, Mar 15 2024
%F A371201 a(n) = prime(n) + A054265(n), for n >= 1. - _Michel Marcus_, Mar 15 2024
%F A371201 a(n) = (prime(n+1)-prime(n))*(prime(n+1)+prime(n)-1)/2 for n>=1. - _Chai Wah Wu_, Jun 01 2024
%e A371201 a(0) = 1.
%e A371201 a(1) = 2.
%e A371201 a(2) = 3 + 4 = 7.
%e A371201 a(3) = 5 + 6 = 11.
%e A371201 a(4) = 7 + 8 + 9 + 10 = 34.
%e A371201 a(5) = 11 + 12 = 23.
%e A371201 a(6) = 13 + 14 + 15 + 16 = 58.
%e A371201 a(7) = 17 + 18 = 35.
%e A371201 The natural numbers are summed in groups where each prime begins a new group,
%e A371201   primes     v   v       v       v
%e A371201          1   2   3   4   5   6   7   8   9  10  ...
%e A371201         \-/ \-/ \-----/ \-----/ \-------------/
%e A371201   a(n) = 1   2     7       11          34
%e A371201     n  = 0   1     2       3           4
%p A371201 ithprime(0):=1:
%p A371201 a:= n-> ((j, k)-> (k-1+j)*(k-j)/2)(map(ithprime, [n, n+1])[]):
%p A371201 seq(a(n), n=0..56);  # _Alois P. Heinz_, Mar 16 2024
%t A371201 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 *)
%o A371201 (PARI)
%o A371201 first(n) = {
%o A371201 	my(res = primes(n), t = 0);
%o A371201 	for(i = 1, n,
%o A371201 		res[i] = binomial(res[i],2) - t;
%o A371201 		t+=res[i];
%o A371201 	);
%o A371201 	res	
%o A371201 } \\ _David A. Corneth_, Mar 16 2024
%o A371201 (Python)
%o A371201 from sympy import nextprime, prime
%o A371201 def A371201(n):
%o A371201     if n == 0: return 1
%o A371201     q = nextprime(p:=prime(n))
%o A371201     return (q-p)*(p+q-1)>>1 # _Chai Wah Wu_, Jun 01 2024
%Y A371201 Cf. A000040, A054265, A138383.
%Y A371201 Cf. A008837 (partial sums).
%K A371201 nonn,easy
%O A371201 0,2
%A A371201 _Raul Prisacariu_, Mar 15 2024
%E A371201 More terms from _Michel Marcus_, Mar 15 2024