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.

A318789 For n >= 3, a(n) is equal to n-1 plus the alternating sum of all consecutive prime gaps between odd primes <= n.

This page as a plain text file.
%I A318789 #46 Dec 11 2019 06:45:25
%S A318789 2,3,2,3,6,7,8,9,6,7,10,11,12,13,10,11,14,15,16,17,14,15,16,17,18,19,
%T A318789 26,27,26,27,28,29,30,31,38,39,40,41,38,39,42,43,44,45,42,43,44,45,46,
%U A318789 47,54,55,56,57,58,59,54,55,58,59,60,61,62,63,58,59,60,61,66,67,66,67,68
%N A318789 For n >= 3, a(n) is equal to n-1 plus the alternating sum of all consecutive prime gaps between odd primes <= n.
%C A318789 Beginning at prime(2)=3, group all primes into even/odd-indexed pairs, (prime(2n), prime(2n+1)).  Then a(prime(2n)) and a(prime(2n+1)) are both equal to 2*A077133(n).
%C A318789 This sequence consists of runs of an even number of consecutive numbers. - _David A. Corneth_, Dec 18 2018
%H A318789 David A. Corneth, <a href="/A318789/b318789.txt">Table of n, a(n) for n = 3..10002</a>
%F A318789 a(3) = 2. a(n + 1) = a(n) + 1 for composite n + 1. For prime n + 1, a(n + 1) = a(n) + 1 - (n + 1 - p) where p is the largest prime < (n + 1). - _David A. Corneth_, Dec 18 2018
%e A318789 a(12)=7 because the alternating sum of all consecutive prime gaps for all odd primes less than/equal to 12 is -2+2-4, and 11+(-2+2-4)=7.
%e A318789 a(13)=10 because the alternating sum of all consecutive prime gaps for all odd primes less than/equal to 13 is -2+2-4+2=-2, and 12+(-2+2-4+2)=10.
%o A318789 (PARI) first(n) = my(res = vector(n), p = 3, sgn = 1, primegap = 0); res[1] = 2; for(i = 2, n, res[i] = res[i-1]+1; if(isprime(i+2), sgn=-sgn; primegap = i+2-p; res[i]+=sgn*primegap; p = i+2)); res \\ _David A. Corneth_, Dec 18 2018
%K A318789 nonn,easy
%O A318789 3,1
%A A318789 _Christopher Hohl_, Dec 15 2018