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.

Previous Showing 11-20 of 30 results. Next

A077133 a(n) is the difference between the sum of the first n even-indexed primes and the sum of the first n odd-indexed primes.

Original entry on oeis.org

1, 3, 5, 7, 13, 19, 21, 27, 29, 33, 39, 45, 49, 53, 57, 61, 63, 65, 71, 77, 79, 81, 83, 95, 97, 103, 113, 119, 121, 125, 135, 139, 143, 149, 151, 157, 163, 167, 175, 183, 185, 187, 191, 199, 201, 213, 217, 221, 233, 251, 261, 267, 273, 279, 281, 287, 289, 299
Offset: 1

Views

Author

Jon Perry, Nov 29 2002

Keywords

Comments

Some odd numbers such as 11, 17, 23 and 25 never appear.

Examples

			a(2) = 3 as the sum of the first 2 even-indexed primes is prime(2) + prime(4) = 3 + 7 = 10, the sum of the first 2 odd-indexed primes is prime(1) + prime(3) = 2 + 5 = 7 and 10 - 7 = 3. [edited by _Paolo Xausa_, Apr 12 2023]
		

Crossrefs

Programs

  • Maple
    with(numtheory): A008347 := proc(n) option remember; if n = 0 then 0 else abs(A008347(n-1)-ithprime(n)); fi; end proc:
    seq(A008347(2n),n=1..80); # Ridouane Oudra, Aug 31 2019
  • Mathematica
    Table[ Sum[ Prime[2i], {i, 1, n}] - Sum[ Prime[2i - 1], {i, 1, n}], {n, 1, 60}]
    A077133[nmax_]:=Accumulate[Prime[Range[2,2nmax,2]]-Prime[Range[1,2nmax,2]]];A077133[100] (* Paolo Xausa, Apr 12 2023 *)
  • PARI
    my(pc=1, p1s=0, p2s=0); forprime (p=2, 500, pc=!pc; if (pc, p1s+=p, p2s+=p); if (pc,print1(p1s-p2s, ", ")))

Formula

a(n) = Sum_{i=0..n-1} (prime(2*i+2) - prime(2*i+1)).
a(n) = A008347(2n). - Ridouane Oudra, Aug 31 2019
a(n) = A077126(n) - A077131(n). - Michel Marcus, Oct 05 2019

Extensions

Edited and extended by Robert G. Wilson v, Nov 30 2002
Name clarified by Paolo Xausa, Apr 12 2023

A181901 a(n) = least positive integer m such that 2(s_k)^2 for k=1,...,n are pairwise distinct modulo m where s_k = Sum_{j=1..k} (-1)^(k-j)*p_j and p_j is the j-th prime.

Original entry on oeis.org

1, 4, 7, 9, 13, 17, 19, 23, 25, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233
Offset: 1

Views

Author

Zhi-Wei Sun, Mar 31 2012

Keywords

Comments

On Mar 28 2012, Zhi-Wei Sun conjectured that a(n) is the (n+1)-th prime p_{n+1} with the only exceptions being a(1)=1, a(2)=4, a(4)=9 and a(9)=25. He has shown that 2(s_k)^2 (k=1,...,n) are indeed pairwise distinct modulo p_{n+1} and hence a(n) does not exceed p_{n+1}.
Note that the sequence 0,s_1,s_2,s_3,... is A008347 introduced by N. J. A. Sloane and J. H. Conway.
Compare a(n) with the sequence A210640.
The conjecture was verified for n up to 2*10^5 by the author in 2018, and for n up to 3*10^5 by Chang Zhang (a student at Nanjing Univ.) in June 2020. - Zhi-Wei Sun, Jun 22 2020

Examples

			We have a(4)=9 since 2(s_1)^2=8, 2(s_2)^2=2, 2(s_3)^2=32, 2(s_4)^2=18 are pairwise distinct modulo 9 but not pairwise distinct modulo any of 1,...,8.
		

Crossrefs

Programs

  • Mathematica
    s[n_]:=Sum[(-1)^k*Prime[k],{k,1,n}]
    f[n_]:=2*s[n]^2
    R[n_,m_]:=Union[Table[Mod[f[k],m],{k,1,n}]]
    Do[Do[If[Length[R[n,m]]==n,Print[n," ",m];Goto[aa]],{m,1,Prime[n+1]}];
       Print[n];Label[aa];Continue,{n,1,600}]

A240860 a(n) = Sum_{i=1..n} (-1)^{i+1} prime(i)^2, where prime(k) denotes the k-th prime: alternating sum of the squares of the first n primes.

Original entry on oeis.org

4, -5, 20, -29, 92, -77, 212, -149, 380, -461, 500, -869, 812, -1037, 1172, -1637, 1844, -1877, 2612, -2429, 2900, -3341, 3548, -4373, 5036, -5165, 5444, -6005, 5876, -6893, 9236, -7925, 10844, -8477, 13724, -9077, 15572, -10997, 16892, -13037, 19004, -13757
Offset: 1

Views

Author

Timothy Varghese, May 06 2014

Keywords

Comments

For n even this is the negative of the sum of (3^2 - 2^2) + (7^2 - 5^2) + ... + (prime(n)^2 - prime(n-1)^2). But this is half of the terms in the sum of (3^2 - 2^2) + (5^2 - 3^2) + (7^2 - 5^2) + ... + (prime(n)^2 - prime(n-1)^2) which has a sum that telescopes to prime(n)^2 - 4. Thus a good estimate of a(n) (half the terms) is prime(n)^2/2 (half the square of the n-th prime) which works well up to n = 10000. For odd n, add prime(n)^2 to the estimate for even n.

Crossrefs

Programs

  • PARI
    a(n) = sum(i=1, n, (-1)^(i+1)*prime(i)^2); \\ Michel Marcus, May 09 2014

A213202 Number of ways to write n = p + sum_{k=1..m}(-1)^(m-k)*p_k, where p is a Sophie Germain prime and p_k is the k-th prime.

Original entry on oeis.org

0, 0, 1, 2, 2, 3, 3, 2, 2, 3, 1, 2, 2, 2, 3, 2, 1, 3, 2, 1, 3, 1, 3, 5, 2, 2, 3, 2, 3, 4, 4, 4, 2, 3, 3, 3, 3, 2, 1, 2, 4, 5, 4, 4, 4, 2, 3, 3, 4, 4, 3, 2, 1, 4, 6, 6, 4, 4, 4, 4, 4, 4, 4, 2, 3, 3, 5, 6, 2, 2, 1, 4, 4, 5, 3, 3, 1, 2, 5, 4, 5, 5, 2, 4, 5, 7, 2, 5, 1, 5, 4, 4, 4, 6, 3, 2, 6, 4, 5, 4
Offset: 1

Views

Author

Zhi-Wei Sun, Mar 01 2013

Keywords

Comments

Conjecture: a(n)>0 for all n>2.
This has been verified for n up to 10^7.
Let s_n=sum_{k=1}^n(-1)^{n-k}p_k for n=1,2,3,... The author also made the following conjectures:
(1) For each n>2, there is an integer k>0 such that 3(n-s_k)-1 and 3(n-s_k)+1 are twin primes.
(2) For each n>3, there is an integer k>0 such that 3(n-s_k)-2 and 3(n-s_k)+2 are cousin primes.
(3) Every n=6,7,... can be written as p+s_k (k>0) with p and p+6 sexy primes.
(4) Any integer n>3 different from 65 and 365 can be written as p+s_k (k>0) with p a term of A210479.
(5) Each integer n>8 can be written as q+s_k (k>0) with q-4, q, q+4 all practical.
(6) Any integer n>1 can be written as j(j+1)/2+s_k with j,k>0.

Examples

			a(11)=1 since 11=3+p_5-p_4+p_3-p_2+p_1 with 3 and 2*3+1 both prime.
a(182)=1 since 182=179+(7-5+3-2) with 179 and 2*179+1 both prime.
		

Crossrefs

Programs

  • Mathematica
    sp[n_]:=qq[n]=PrimeQ[n]&&PrimeQ[2n+1]
    s[0_]:=0
    s[n_]:=s[n]=Prime[n]-s[n-1]
    a[n_]:=a[n]=Sum[If[n-s[m]>0&&sp[n-s[m]],1,0],{m,1,n}]
    Do[Print[n," ",a[n]],{n,1,100}]

A226913 Not of form sum_{i=0..n-1} (-1)^i prime(n-i), where prime(k) denotes the k-th prime.

Original entry on oeis.org

6, 9, 10, 11, 14, 15, 17, 20, 23, 24, 25, 28, 30, 31, 34, 35, 36, 37, 41, 42, 43, 46, 47, 48, 50, 51, 55, 58, 59, 60, 62, 64, 66, 67, 68, 69, 72, 73, 74, 75, 78, 80, 82, 84, 85, 87, 88, 89, 90, 91, 93, 94, 98, 99, 100, 101, 104, 105, 106, 107, 108, 109, 110, 111, 114, 115, 117, 118, 120, 122, 123, 124
Offset: 1

Views

Author

Ralf Stephan, Sep 01 2013

Keywords

Comments

Complement of A008347.

A242266 a(n) = |{0 < g < prime(n): g is a primitive root mod prime(n) with g = sum_{j=1..k} prime(j) for some k > 0}|.

Original entry on oeis.org

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

Views

Author

Zhi-Wei Sun, May 09 2014

Keywords

Comments

Conjecture: (i) a(n) > 0 for all n > 1. In other words, for any odd prime p, there is a positive integer k such that the sum of the first k primes is not only a primitive root modulo p but also smaller than p.
(ii) For any n > 1, there is a number k among 1, ..., n such that sum_{j=1..k}(-1)^(k-j)*prime(j) is a primitive root modulo prime(n).
We have verified parts (i) and (ii) for n up to 700000 and 250000 respectively. Note that prime(700000) > 10^7.

Examples

			a(4) = 1 since prime(1) + prime(2) = 2 + 3 = 5 is a primitive root modulo prime(4) = 7 with 5 < 7.
a(7) = 2 since prime(1) = 2 and prime(1) + prime(2) + prime(3) = 2 + 3 + 5 = 10 are not only primitive roots modulo prime(7) = 17 but also smaller than 17.
a(53) = 1 since sum_{j=1..10} prime(j) = 129 is a primitive root modulo prime(53) = 241 with 129 < 241.
		

Crossrefs

Programs

  • Mathematica
    f[0]=0
    f[n_]:=Prime[n]+f[n-1]
    dv[n_]:=Divisors[n]
    Do[m=0;Do[If[f[k]>=Prime[n],Goto[cc]];Do[If[Mod[f[k]^(Part[dv[Prime[n]-1],i]),Prime[n]]==1,Goto[aa]],{i,1,Length[dv[Prime[n]-1]]-1}];m=m+1;Label[aa];Continue,{k,1,n}];Label[cc];Print[n," ",m];Continue,{n,1,80}]

A121573 Prime-gap race; difference of the cumulative sums of gaps above and below prime(2n).

Original entry on oeis.org

1, 3, 5, 7, 3, 1, 3, 3, 7, 5, 3, 5, 3, 1, 11, 13, 21, 25, 23, 23, 31, 33, 43, 35, 37, 33, 29, 29, 33, 31, 35, 33, 43, 47, 49, 51, 51, 53, 49, 51, 59, 63, 65, 61, 63, 59, 63, 65, 55, 43, 39, 35, 39, 39, 43, 41, 51, 43, 45, 41, 33, 35, 33, 31, 31, 35, 33, 29, 25, 15, 7, 5, 9, 7, 17, 15, 31, 35, 33, 35, 43, 45, 47, 53, 55, 63, 67, 59, 51, 63, 61
Offset: 1

Views

Author

T. D. Noe, Aug 08 2006

Keywords

Comments

This sequence was inspired by seeing two lines in the plot of A008347. It was expected that, on average, the gaps above prime(2n) would be larger than the gaps below prime(2n) and hence a(n) would be a mostly positive sequence. With some exceptions, this is true for the first 6330 terms. However, as the plot shows, over 500000 negative terms follow!

Examples

			a(6)=1 because the prime gaps above and below the even-indexed primes (3,7,13,19,29,37) are 2,4,4,4,2,4 and 1,2,2,2,6,6, respectively. The sums of these gaps are 20 and 19, which differ by 1.
		

Crossrefs

Cf. A008347 (alternating sum of primes), A036263 (second difference of primes).

Programs

  • Haskell
    a121573 n = a121573_list !! (n-1)
    a121573_list = scanl1 (+) $ map a036263 [1, 3 ..]
    -- Reinhard Zumkeller, Aug 02 2012
  • Mathematica
    s=0; Table[s=s+Prime[2n-1]+Prime[2n+1]-2*Prime[2n], {n,115}]
    With[{g=Transpose[Differences/@Partition[Prime[Range[400]],3,2]]}, Accumulate[g[[2]]]-Accumulate[g[[1]]]](* Harvey P. Dale, May 28 2013 *)

Formula

a(n) = Sum_{k=1..n} (prime(2k+1) - prime(2k)) - Sum_{k=1..n} (prime(2k) - prime(2k-1)).
a(n) = Sum_{k=1..n} A036263(2k-1).
a(n) = prime(2n+1) - 2*A008347(2n) - 2.

Extensions

Typo in Formula fixed by Reinhard Zumkeller, Aug 02 2012

A131196 Numbers n such that 1 + S(n) = 0, where S(n) = (S(n-1) + A000040(n))*(-1)^n; S(0)=0, n=>1.

Original entry on oeis.org

22, 38, 200, 302, 468, 560, 1186, 1208, 2006, 2026, 2106, 23698, 23716, 25968, 25990, 26706, 48316, 311888, 311914, 311938, 313866, 331540, 332002, 377102, 377634, 377670, 377748, 378428, 378452, 378996, 379026, 379090, 387618, 388140, 389398
Offset: 1

Views

Author

Manuel Valdivia, Sep 26 2007

Keywords

Comments

The terms are equal to A130642 for n/2 even (70 terms) and to A130643 for n/2 odd (91 terms).

Examples

			S(21)=(..((((0+2)*-1)+3)*1)+5)*-1)+7)*1)+11)*- 1)+13)*1)+...+71)*1)+73)*-1 = -80, 1 + S(22) =1 + (-80 + 79)*1 = 0, hence 22 is a term.
S(37)=(..((((0+2)*-1)+3)*1)+5)*-1)+7)*1)+11)*- 1)+13)*1)+...+151)*1)+157)*-1 = -164, 1 + S(38) =1 + (-164 + 163)*1 = 0, hence 38 is a term.
		

Crossrefs

Programs

  • Mathematica
    S=0;a=0; Do[S=(S+Prime[n])*(-1)^n; If[1+S==0,a++; Print[a," ",n]], {n, 1, 10^8, 1}]

A131197 Numbers n such that 1 - S(n) = 0, where S(n) = (S(n-1) + A000040(n))*(-1)^n; S(0)=0, n=>1.

Original entry on oeis.org

2, 4, 6, 8, 12, 14, 190, 194, 306, 308, 462, 464, 472, 474, 476, 478, 490, 1884, 1890, 1938, 23636, 23656, 23850, 25226, 25834, 25984, 26642, 26650, 26924, 26998, 27000, 311922, 313880, 313946, 331676, 331762, 331782, 332676, 377078, 377518, 377666
Offset: 1

Views

Author

Manuel Valdivia, Sep 26 2007

Keywords

Comments

The terms are equal to A130642 for n/2 odd (100 terms) and to A130643 for n/2 even (86 terms).

Examples

			S(11)=(..((((0+2)*-1)+3)*1)+5)*-1)+7)*1)+11)*- 1)+13)*1)+...+29)*1)+31)*-1 = -36, 1 - S(12)=1 - (-36 + 37)*1 = 0, hence 12 is a term.
S(13)=(..((((0+2)*-1)+3)*1)+5)*-1)+7)*1)+11)*- 1)+13)*1)+...+37)*1)+41)*-1 = -42, 1 - S(14)=1 - (-42 + 43)*1 = 0, hence 14 is a term.
		

Crossrefs

Programs

  • Mathematica
    S=0;a=0; Do[S=(S+Prime[n])*(-1)^n; If[1-S==0,a++; Print[a," ",n]], {n, 1, 10^8, 1}]

A136288 Primes which are the absolute value of the alternating sum and difference of the first n primes.

Original entry on oeis.org

2, 3, 5, 7, 13, 19, 29, 53, 61, 71, 79, 83, 97, 103, 113, 139, 149, 151, 157, 163, 167, 191, 199, 233, 251, 281, 337, 347, 353, 397, 421, 433, 461, 563, 599, 643, 719, 773, 797, 811, 859, 883, 953, 977, 1031, 1039, 1061, 1063, 1091, 1097, 1153, 1187, 1201, 1213
Offset: 1

Views

Author

Keywords

Examples

			5 = abs(2-3+5-7+11-13) (first 6 primes),
7 = abs(2-3+5-7+11-13+17-19) (first 8 primes),
etc.
		

Crossrefs

Programs

  • Maple
    P:=proc(n) local i,s; s:=0; for i from 1 by 1 to n do s:=s+(-1)^i*ithprime(i); if isprime(abs(s)) then print(abs(s)); fi; od; end: P(1000);
  • Mathematica
    Select[Abs@Accumulate@Table[(-1)^(k+1)*Prime@k,{k,355}],PrimeQ] (* Giorgos Kalogeropoulos, Sep 22 2021 *)

Formula

A000040 INTERSECT A008347. - R. J. Mathar, Apr 04 2008
Previous Showing 11-20 of 30 results. Next