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.

Showing 1-9 of 9 results.

A046080 a(n) is the number of integer-sided right triangles with hypotenuse n.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Or number of ways n^2 can be written as the sum of two positive squares: a(5) = 1: 3^2 + 4^2 = 5^2; a(25) = 2: 7^2 + 24^2 = 15^2 + 20^2 = 25^2. - Alois P. Heinz, Aug 01 2019

References

  • A. H. Beiler, Recreations in the Theory of Numbers, New York: Dover, pp. 116-117, 1966.

Crossrefs

First differs from A083025 at n=65.
A088111 gives records; A088959 gives where records occur.
Partial sums: A224921.

Programs

  • Maple
    f:= proc(n) local F,t;
      F:= select(t -> t[1] mod 4 = 1, ifactors(n)[2]);
      1/2*(mul(2*t[2]+1, t=F)-1)
    end proc:
    map(f, [$1..100]); # Robert Israel, Jul 18 2016
  • Mathematica
    a[1] = 0; a[n_] := With[{fi = Select[ FactorInteger[n], Mod[#[[1]], 4] == 1 & ][[All, 2]]}, (Times @@ (2*fi+1)-1)/2]; Table[a[n], {n, 1, 99}] (* Jean-François Alcover, Feb 06 2012, after first formula *)
  • PARI
    a(n)={my(m=0,k=n,n2=n*n,k2,l2);
    while(1,k=k-1;k2=k*k;l2=n2-k2;if(l2>k2,break);if(issquare(l2),m++));return(m)} \\ brute force, Stanislav Sykora, Mar 18 2015
    
  • PARI
    {a(n) = if( n<1, 0, sum(k=1, sqrtint(n^2 \ 2), issquare(n^2 - k^2)))}; /* Michael Somos, Mar 29 2015 */
    
  • PARI
    a(n) = {my(f = factor(n/(2^valuation(n, 2)))); (prod(k=1, #f~, if ((f[k,1] % 4) == 1, 2*f[k,2] + 1, 1)) - 1)/2;} \\ Michel Marcus, Mar 08 2016
    
  • Python
    from math import prod
    from sympy import factorint
    def A046080(n): return prod((e<<1)+1 for p,e in factorint(n).items() if p&3==1)>>1 # Chai Wah Wu, Sep 06 2022

Formula

Let n = 2^e_2 * product_i p_i^f_i * product_j q_j^g_j where p_i == 1 mod 4, q_j == 3 mod 4; then a(n) = (1/2)*(product_i (2*f_i + 1) - 1). - Beiler, corrected
8*a(n) + 4 = A046109(n) for n > 0. - Ralf Stephan, Mar 14 2004
a(n) = 0 for n in A004144. - Lekraj Beedassy, May 14 2004
a(A084645(k)) = 1. - Ruediger Jehn, Jan 14 2022
a(A084646(k)) = 2. - Ruediger Jehn, Jan 14 2022
a(A084647(k)) = 3. - Jean-Christophe Hervé, Dec 01 2013
a(A084648(k)) = 4. - Jean-Christophe Hervé, Dec 01 2013
a(A084649(k)) = 5. - Jean-Christophe Hervé, Dec 01 2013
a(n) = A063725(n^2) / 2. - Michael Somos, Mar 29 2015
a(n) = Sum_{k=1..n} Sum_{i=1..k} [i^2 + k^2 = n^2], where [ ] is the Iverson bracket. - Wesley Ivan Hurt, Dec 10 2021
a(A002144(k)^n) = n. - Ruediger Jehn, Jan 14 2022

A247588 Number of integer-sided acute triangles with largest side n.

Original entry on oeis.org

1, 2, 3, 5, 6, 8, 11, 13, 15, 17, 21, 25, 27, 31, 34, 39, 43, 48, 52, 56, 63, 67, 73, 80, 84, 90, 96, 104, 111, 117, 126, 132, 140, 147, 154, 165, 172, 183, 189, 198, 210, 219, 229, 237, 247, 260, 270, 282, 292, 302
Offset: 1

Views

Author

Vladimir Letsko, Sep 20 2014

Keywords

Examples

			a(3) = 3 because there are 3 integer-sided acute triangles with largest side 3: (1,3,3); (2,3,3); (3,3,3).
		

Crossrefs

Programs

  • Maple
    tr_a:=proc(n) local a,b,t,d;t:=0:
    for a to n do
    for b from max(a,n+1-a) to n do
    d:=a^2+b^2-n^2:
    if d>0 then t:=t+1 fi
    od od;
    t; end;
  • Mathematica
    a[ n_] := Length @ FindInstance[ n >= b >= a >= 1 && n < b + a && n^2 < b^2 + a^2, {a, b}, Integers, 10^9]; (* Michael Somos, May 24 2015 *)
  • PARI
    a(n) = sum(j=0, n*(1 - sqrt(2)/2), n - j - floor(sqrt(2*j*n - j^2))); \\ Michel Marcus, Oct 07 2014
    
  • PARI
    {a(n) = sum(j=0, n - sqrtint(n*n\2) - 1, n - j - sqrtint(2*j*n - j*j))}; /* Michael Somos, May 24 2015 */

Formula

a(n) = Sum_{j=0..floor(n*(1 - sqrt(2)/2))} (n - j - floor(sqrt(2*j*n - j^2))). - Anton Nikonov, Oct 06 2014
a(n) = (1/8)*(-4*ceiling((n - 1)/sqrt(2)) + 4*n^2 - A000328(n) + 1), n > 1. - Mats Granvik, May 23 2015

A379830 a(n) is the number of Pythagorean triples (u, v, w) for which w - u = n where u < v < w.

Original entry on oeis.org

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

Views

Author

Felix Huber, Jan 07 2025

Keywords

Comments

The difference between the hypotenuse and the short leg of a primitive Pythagorean triple (p^2 - q^2, 2*p*q, p^2 + q^2) (where p > q are coprimes and not both odd) is d = max(2*q^2, (p - q)^2). For every of these primitive Pythagorean triples whose d divides n, there is a Pythagorean triple with w - u = n. Therefore d <= n and it follows that 1 <= q <= sqrt(n/2) and q + 1 <= p <= q + sqrt(n), which means that there is a finite number of Pythagorean triples with w - u = n.

Examples

			The a(18) = 4 Pythagorean triples are (27, 36, 45), (16, 30, 34), (40, 42, 58), (7, 24, 25) because 45 - 27 = 34 - 16 = 58 - 40 = 25 - 7 = 18.
See also linked Maple program "Pythagorean triples for which w - u = n".
		

Crossrefs

Programs

  • Maple
    A379830:=proc(n)
        local a,p,q;
        a:=0;
        for q to isqrt(floor(n/2)) do
            for p from q+1 to q+isqrt(n) do
                if igcd(p,q)=1 and (is(p,even) or is(q,even)) and n mod max((p-q)^2,2*q^2)=0 then
                    a:=a+1
                fi
            od
        od;
        return a
    end proc;
    seq(A379830(n),n=0..87);

A247587 Number of obtuse triangles with integer sides at most n.

Original entry on oeis.org

0, 0, 1, 2, 4, 8, 13, 20, 30, 42, 57, 74, 95, 120, 149, 182, 219, 261, 309, 362, 420, 485, 556, 632, 715, 806, 906, 1012, 1125, 1247, 1377, 1517, 1666, 1824, 1993, 2170, 2358, 2555, 2765, 2986
Offset: 1

Views

Author

Vladimir Letsko, Sep 20 2014

Keywords

Examples

			a(4) = 2 because there are 2 obtuse triangles with integer sides less than or equal to 4: (2,2,3); (2,3,4).
		

Crossrefs

Programs

  • Maple
    tr_o:=proc(n) local a, b, c, t, d; t:=0:
      for a to n do
      for b from a to n do
      for c from b to min(a+b-1, n) do
      d:=a^2+b^2-c^2:
      if d<0 then t:=t+1 fi
      od od od;
      [n, t]; end;
  • PARI
    a(n)=sum(a=2,n-1,sum(b=a,n-1,max(0,min(n,a+b-1)-sqrtint(a^2+b^2)))) \\ Charles R Greathouse IV, Sep 20 2014
    
  • PARI
    obtuse(n)=sum(a=2,n-1, max(0, sqrtint(n^2-1-a^2)-max(a,n-a+1)+1))
    s=0; vector(100,n, s+=obtuse(n)) \\ Charles R Greathouse IV, Sep 20 2014

A156685 Number of primitive Pythagorean triples A^2 + B^2 = C^2 with 0 < A < B < C and gcd(A,B)=1 that have a hypotenuse C that is less than or equal to n.

Original entry on oeis.org

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

Views

Author

Ant King, Feb 17 2009

Keywords

Comments

D. N. Lehmer has proved that the asymptotic density of a(n) is a(n)/n = 1/(2*Pi) = 0.1591549...

Examples

			There is one primitive Pythagorean triple with a hypotenuse less than or equal to 7 -- (3,4,5) -- hence a(7)=1.
G.f. = x^5 + x^6 + x^7 + x^8 + x^9 + x^10 + x^11 + x^12 + 2*x^13 + 2*x^14 + ...
		

References

  • Lehmer, Derrick Norman; Asymptotic Evaluation of Certain Totient Sums, American Journal of Mathematics, Vol. 22, No. 4, (Oct. 1900), pp. 293-335.

Crossrefs

Programs

  • Haskell
    a156685 n = a156685_list !! (n-1)
    a156685_list = scanl1 (+) a024362_list  -- Reinhard Zumkeller, Dec 02 2012
    
  • Mathematica
    RightTrianglePrimitiveHypotenuses[1]:=0;RightTrianglePrimitiveHypotenuses[n_Integer?Positive]:=Module[{f=Transpose[FactorInteger[n]],a,p,mod1posn},{p,a}=f;mod1=Select[p,Mod[ #,4]==1&];If[Length[a]>Length[mod1],0,2^(Length[mod1]-1)]];RightTrianglePrimitiveHypotenuses[ # ] &/@Range[75]//Accumulate
  • PARI
    a(n)=sum(a=1,n-2,sum(b=a+1,sqrtint(n^2-a^2), gcd(a,b)==1 && issquare(a^2+b^2))) \\ Charles R Greathouse IV, Apr 29 2013

Formula

Essentially partial sums of A024362.

A247586 Number of acute triangles with integer sides less than or equal to n.

Original entry on oeis.org

1, 3, 6, 11, 17, 25, 36, 49, 64, 81, 102, 127, 154, 185, 219, 258, 301, 349, 401, 457, 520, 587, 660, 740, 824, 914, 1010, 1114, 1225, 1342, 1468, 1600, 1740, 1887, 2041, 2206, 2378, 2561, 2750, 2948
Offset: 1

Views

Author

Vladimir Letsko, Sep 20 2014

Keywords

Examples

			a(2) = 3 because there are 3 acute triangles with integer sides less than or equal to 2: (1,1,1); (1,2,2); (2,2,2).
		

Crossrefs

Programs

  • Maple
    tr_a:=proc(n) local a,b,c,t,d;t:=0:
      for a to n do
      for b from a to n do
      for c from b to min(a+b-1,n) do
      d:=a^2+b^2-c^2:
      if d>0 then t:=t+1 fi
      od od od;
      [n,t]; end;
  • Mathematica
    a[n_] := Module[{a, b, c, d, t = 0}, Do[d = a^2 + b^2 - c^2; If[d>0, t++], {a, n}, {b, a, n}, {c, b, Min[a+b-1, n]}]; t]; Array[a, 40] (* Jean-François Alcover, Jun 19 2019, from Maple *)
  • Python
    import itertools
    def A247586(n):
        I = itertools.combinations_with_replacement(range(1,n+1),3)
        F = filter(lambda c: c[0]**2 + c[1]**2 > c[2]**2, I)
        return len(list(F))
    print([A247586(n) for n in range(41)]) # Peter Luschny, Sep 22 2014

A224932 Maximal side length b <= a = n of integer parallelograms.

Original entry on oeis.org

0, 0, 0, 3, 5, 0, 6, 6, 8, 10, 10, 11, 13, 13, 15, 15, 17, 16, 18, 20, 20, 21, 21, 23, 25, 26, 26, 27, 29, 30, 29, 31, 31, 34, 35, 33, 37, 37, 39, 40, 41, 41, 41, 43, 45, 45, 46, 46, 48, 50
Offset: 1

Views

Author

Reiner Moewald, Apr 20 2013

Keywords

Crossrefs

A247589 Number of integer-sided obtuse triangles with largest side n.

Original entry on oeis.org

0, 0, 1, 1, 2, 4, 5, 7, 10, 12, 15, 17, 21, 25, 29, 33, 37, 42, 48, 53, 58, 65, 71, 76, 83, 91, 100, 106, 113, 122, 130, 140, 149, 158, 169, 177, 188, 197, 210, 221, 230, 243, 255, 269, 281, 292, 306, 318, 333, 346
Offset: 1

Views

Author

Vladimir Letsko, Sep 20 2014

Keywords

Examples

			a(5) = 2 because there are 2 integer-sided acute triangles with largest side 5: (2,4,5); (3,3,5).
		

Crossrefs

Programs

  • Maple
    tr_o:=proc(n) local a,b,t,d;t:=0:
    for a to n do
    for b from max(a,n+1-a) to n do
    d:=a^2+b^2-n^2:
    if d<0 then t:=t+1 fi
    od od;
    t; end;

Formula

a(n) = k*(k + (1+(-1)^n)/2) + Sum_{j=1..floor(n*(1-sqrt(2)/2))} floor(sqrt(2*j*n - j^2 - 1) - j), where k = floor((2*n*(sqrt(2) - 1) + 1 - (-1)^n)/4) (it appears that k(n) is A070098(n)). - Anton Nikonov, Sep 29 2014

A383181 Family of 2-colorings of {1..7824} with no monochromatic Pythagorean triples.

Original entry on oeis.org

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

Views

Author

David Dewan, Apr 18 2025

Keywords

Comments

We use the codes: 1=red, 2=blue, 0=unconstrained (may be red or blue).
Choose any Pythagorean triangle (r,s,t) with t<=7824, then a(r), a(s), a(t) cannot all be the same color (see Examples).
Solution and proof by Heule, Kullmann, and Marek (2016).
Because each of the 2899 numbers for which a(n)=0 can be independently colored red or blue, this sequence represents 2^2899 unique 2-colorings with no monochromatic Pythagorean triples.
There is no 2-coloring of {1..7825} with no monochromatic Pythagorean triples.

Examples

			The triple (5,12,13) is not monochromatic:
  a(5)= 1 red,
  a(12)=2 blue,
  a(13)=2 blue.
The triple (3,4,5) is not monochromatic whether 4 is red or blue:
  a(3)=2 blue,
  a(4)=0 red or blue,
  a(5)=1 red.
		

Crossrefs

Showing 1-9 of 9 results.