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.

A073579 Signed primes: if prime(n) even, a(n) = 0; if prime(n) == 1 (mod 4), a(n) = prime(n); if prime(n) == -1 (mod 4), a(n) = -prime(n).

Original entry on oeis.org

0, -3, 5, -7, -11, 13, 17, -19, -23, 29, -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, -239
Offset: 1

Views

Author

Miklos Kristof, Aug 28 2002

Keywords

Comments

Product_{i>1} (1/(1 - 1/a(i))) = 1 - 1/3 + 1/5 - 1/7 - 1/9 + 1/11 ...
= (Pi/4)*Product_{i>1} (1/(1 + 1/a(i)))
= (Pi/2)*Product_{i>1} (1/(1 - 1/a(i)))*Product_{i>1} (1/(1 + 1/a(i)))
= Product_{i>1} (1/(1 - 1/prime(i)^2))
= 1 + 1/3^2 + 1/5^2 + 1/7^2 + 1/9^2 + ...
= Pi^2/8.
Also prime(n)*(2 - prime(n) mod 4) = A000040(n)*A070750(n). - Reinhard Zumkeller, Oct 21 2002
This is a signed version of A160656. - T. D. Noe, Feb 28 2012

Examples

			a(1) = 0 because prime(1)=2 is neither 4k+1 nor 4k-1.
a(6) = 13 = prime(6) because 13 = 4*3 + 1.
a(8) = -19 = -prime(8) because 19 = 4*5 - 1.
		

Crossrefs

Cf. A000040, A160656, A111003 (Pi^2/8).

Programs

  • Haskell
    a073579 n = p * (2 - p `mod` 4) where p = a000040 n
    -- Reinhard Zumkeller, Feb 28 2012
    
  • Magma
    C := ComplexField(); [0] cat [Round(i^(NthPrime(n)-1)*NthPrime(n)): n in [2..100]]; // G. C. Greubel, Dec 31 2019
    
  • Maple
    0, seq(I^(ithprime(n)-1)*ithprime(n), n = 2..100); # G. C. Greubel, Dec 31 2019
  • Mathematica
    Join[{0},If[Mod[#,4]==1,#,-#]&/@Prime[Range[2,60]]] (* Harvey P. Dale, Feb 27 2012 *)
    Join[{0}, Table[p = Prime[n]; If[Mod[p, 4] == 1, p, -p], {n, 2, 100}]] (* T. D. Noe, Feb 28 2012 *)
  • PARI
    forprime(p=2,239,print1(p*(2-p%4),", ")) \\ Hugo Pfoertner, Dec 17 2019
    
  • Sage
    [0]+[I^(nth_prime(n)-1)*nth_prime(n) for n in (2..100)] # G. C. Greubel, Dec 31 2019

Formula

a(1)=0 and for i>1: a(i) = (-1)^((prime(i)-1)/2)*prime(i).

Extensions

Corrected (sign changed on 179) by Harvey P. Dale, Feb 27 2012