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.

A088978 Number of Pythagorean triangles having the n-th prime prime(n) as one of their sides.

Original entry on oeis.org

0, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 2, 2, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1
Offset: 1

Views

Author

Lekraj Beedassy, Oct 31 2003

Keywords

Comments

Primitive Pythagorean triples are given parametrically by (M^2 - N^2)^2 + (2MN)^2 = (M^2 + N^2)^2. Odd primes are uniquely representable (ignoring signs) as M^2 - N^2, but only primes of the form 4k + 1 are uniquely representable as M^2 + N^2. Since 2MN is composite for MN > 1, an odd prime can be a side of one or two Pythagorean triangles. Thus, except for a(1) = 0, a(n) is 2 for prime(n) of the form 4k + 1, and 1 otherwise. - Chris Boyd, Jan 25 2016

Crossrefs

Cf. A046081.

Programs

  • Magma
    [0] cat [(4-NthPrime(n) mod 4+1)/2: n in [2..100]]; // Vincenzo Librandi, Jan 26 2016
  • Maple
    0, seq((4-ithprime(i) mod 4 + 1)/2, i=2..1000); # Robert Israel, Jan 25 2016
  • Mathematica
    Table[(4 - Mod[Prime@ n, 4] + 1)/2, {n, 105}] /. Rational -> 0 (* _Michael De Vlieger, Jan 26 2016 *)
  • PARI
    a088978(n) = my(p=prime(n)); if(p==2,0,if((p-1)%4==0,2,1))
    for(i=1,105,print1(a088978(i),", ")) \\ Chris Boyd, Jan 25 2016
    

Extensions

Corrected and extended by Ray Chandler, Nov 01 2003