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 21-30 of 65 results. Next

A229062 1 if n is representable as sum of two nonnegative squares, otherwise 0.

Original entry on oeis.org

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

Views

Author

Ralf Stephan, Sep 17 2013

Keywords

Comments

Characteristic function of A001481.
a(n) = 1 if A000161(n) > 0.
a(A022544(n)) = 0.
Multiplicative because A002654 is. - Andrew Howroyd, Aug 01 2018
For positive n, m = 2*a(n) + 1 is the smallest positive integer such that m * n is not a sum of two squares. - Peter Schorn, Dec 29 2023

Crossrefs

Cf. A002654, A004018, A070176. Partial sums are in A102548.

Programs

  • Mathematica
    Join[{1},Table[If[SquaresR[2,n]>1,1,0],{n,120}]] (* Harvey P. Dale, Aug 25 2017 *)
  • PARI
    a(n)=my(f=0); my(r=sqrtint(n)); forstep(i=r, 1, -1, if(issquare(n-i*i), f=1; break)); f
    
  • PARI
    a(n)=if(0==n,1,(sumdiv(n, d,(d%4==1) - (d%4==3)) > 0)); \\ Andrew Howroyd, Aug 01 2018, the check for 0-argument added by Antti Karttunen, Apr 22 2022
    
  • Python
    from sympy import factorint
    def A229062(n): return int(all(p & 3 != 3 or e & 1 == 0 for p, e in factorint(n).items())) # Chai Wah Wu, Jun 28 2022

Formula

a(n) = min{1, A004018(n)}. - N. J. A. Sloane, Jan 11 2020

A089982 Triangular numbers that can be expressed as the sum of 2 positive triangular numbers.

Original entry on oeis.org

6, 21, 36, 55, 66, 91, 120, 136, 171, 210, 231, 276, 351, 378, 406, 496, 561, 666, 703, 741, 820, 861, 946, 990, 1035, 1081, 1176, 1225, 1326, 1378, 1431, 1485, 1540, 1596, 1653, 1711, 1770, 1891, 1953, 2016, 2080, 2211, 2278, 2346, 2556, 2701, 2775, 2850
Offset: 1

Views

Author

Jon Perry, Jan 13 2004

Keywords

Comments

Intersection of triangular numbers with sumset of triangular numbers. Triangular number analog of what for squares is {A057100(n)^2} = {A009000(n)^2}. {A000217} INTERSECT {A000217 + A000217}. - Jonathan Vos Post, Mar 09 2007
A subsequence of A051533. - Wolfdieter Lang, Jan 11 2017

Examples

			Generally, A000217(A000217(n)) = A000217(A000217(n)-1) + A000217(n) and so is automatically included. These are 6=T(3), 21=T(6), 55=T(10), etc. Other solutions occur when a partial sum from x to y is triangular, e.g., 15 + 16 + 17 + 18 = 66 = T(11), so T(14) + T(11) = T(18). This particular example arises since 10+4k is triangular (at k=14, 10 + 4k = 66), and we therefore have a solution.
All other solutions occur when 3+2k, 6+3k, 10+4k, etc. -- in general, T(j) + j*k -- is triangular.
		

Crossrefs

Programs

  • Mathematica
    trn[i_]:=Module[{trnos=Accumulate[Range[i]],t2s},t2s=Union[Total/@ Tuples[ trnos,2]];Intersection[trnos,t2s]] (* Harvey P. Dale, Nov 08 2011 *)
    Select[Range[75], ! PrimeQ[#^2 + (# + 1)^2] &] /. Integer_ -> (Integer^2 + Integer)/2 (* Arkadiusz Wesolowski, Dec 03 2015 *)
  • PARI
    t(i) = i*(i+1)/2;
    { v=vector(100,i,t(i)); y=vector(100); c=0; for (i=1,30, for (j=i,30, x=t(i)+t(j); f=0; for (k=1,100,if (x==v[k],f=1;break)); if (f==1,y[c++ ]=x))); select(x->(x>0), vecsort(y,,8)) } \\ slightly edited by Michel Marcus, Apr 15 2021
    
  • PARI
    lista(nn) = {for (n=1, nn, my(t = n*(n+1)/2); for (k=1, n-1, if (ispolygonal(t - k*(k+1)/2, 3), print1(t, ", "); break;)););} \\ Michel Marcus, Apr 15 2021
    
  • Python
    from itertools import count, takewhile
    def aupto(lim):
        t = list(takewhile(lambda x: x<=lim, (i*(i+1)//2 for i in count(1))))
        s = set(a+b for i, a in enumerate(t) for b in t[i:])
        return sorted(s & set(t))
    print(aupto(3000)) # Michael S. Branicky, Jun 21 2021

Formula

Triangular number m is in this sequence iff A000161(4*m+1)>1 or, alternatively, A083025(4*m+1)>1. - Max Alekseyev, Oct 24 2008
a(n) = A000217(A012132(n)). - Ivan N. Ianakiev, Jan 17 2013

Extensions

More terms from Lambert Klasen (Lambert.Klasen(AT)gmx.net) and David Wasserman, Sep 23 2005

A124982 Nonprime numbers with a unique partition as a sum of 2 squares x^2 + y^2.

Original entry on oeis.org

0, 1, 4, 8, 9, 10, 16, 18, 20, 26, 32, 34, 36, 40, 45, 49, 52, 58, 64, 68, 72, 74, 80, 81, 82, 90, 98, 104, 106, 116, 117, 121, 122, 128, 136, 144, 146, 148, 153, 160, 162, 164, 178, 180, 194, 196, 202, 208, 212, 218, 226, 232, 234, 242, 244, 245, 256, 261, 272, 274
Offset: 1

Views

Author

Artur Jasinski, Nov 16 2006

Keywords

Crossrefs

Programs

  • Mathematica
    Select[Range[0, 300], !PrimeQ[#] && Length @ PowersRepresentations[#, 2, 2] == 1 &] (* Amiram Eldar, Mar 12 2020 *)
  • PARI
    A000161(n)={ local(cnt=0,y2) ; for(x=0,floor(sqrt(n)), y2=n-x^2 ; if( y2>=x^2 && issquare(y2), cnt++ ; ) ; ) ; return(cnt) ; } isA124982(n)= { if( isprime(n), return(0), if(A000161(n)==1, return(1), return(0) ) ) ; } { for(n=0,300, if( isA124982(n), print1(n,", ") ; ) ; ) ; } \\ R. J. Mathar, Nov 29 2006

Formula

A000161(a(n)) = 1. - R. J. Mathar, Nov 29 2006

Extensions

Corrected and extended by R. J. Mathar, Nov 29 2006

A216282 Number of nonnegative solutions to the equation x^2 + 2*y^2 = n.

Original entry on oeis.org

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

Views

Author

V. Raman, Sep 03 2012

Keywords

Comments

Records occur at 1, 9, 81, 297, 891, 1683, 5049, 15147, 31977, ... - Antti Karttunen, Aug 23 2017

Examples

			For n = 9, there are two solutions: 9 = 9^2 + 2*(0^2) = 1^2 + 2*(2^2), thus a(9) = 2.
For n = 81, there are three solutions: 81 = 9^2 + 2*(0^2) = 3^2 + 2*(6^2) = 7^2 + 2*(4^2), thus a(81) = 3.
For n = 65536, there is one solution: 65536 = 256^2 + 2*(0^2) = 65536 + 0, thus a(65536) = 1.
For n = 65537, there is one solution: 65537 = 255^2 + 2*(16^2) = 65205 + 512, thus a(65537) = 1.
		

Crossrefs

Cf. A002479 (positions of nonzeros), A097700 (of zeros).

Programs

  • Mathematica
    r[n_] := Reduce[x >= 0 && y >= 0 && x^2 + 2 y^2 == n, Integers];
    a[n_] := Which[rn = r[n]; rn === False, 0, Head[rn] === And, 1, Head[rn] === Or, Length[rn], True, -1];
    Table[a[n], {n, 1, 120}] (* Jean-François Alcover, Jun 24 2017 *)
  • Scheme
    (define (A216282 n) (cond ((< n 2) 1) (else (let loop ((k (- (A000196 n) (modulo (- n (A000196 n)) 2))) (s 0)) (if (< k 0) s (let ((x (/ (- n (* k k)) 2))) (loop (- k 2) (+ s (A010052 x))))))))) ;; Antti Karttunen, Aug 23 2017

Extensions

Examples from Antti Karttunen, Aug 23 2017

A050797 Numbers n such that n^2 - 1 is expressible as the sum of two nonzero squares in exactly one way.

Original entry on oeis.org

3, 9, 17, 19, 33, 35, 73, 145, 161, 163, 195, 243, 393, 483, 513, 721, 723, 1153, 1763, 2177, 2305, 2593, 4803, 5185, 5833, 6273, 6963, 7057, 7395, 8713, 9523, 9603, 10083, 12483, 13923, 14113, 15875, 17425, 17673, 19043, 20737
Offset: 1

Views

Author

Patrick De Geest, Sep 15 1999

Keywords

Comments

If the definition were changed from "nonzero squares" to "nonnegative squares", there would be just one additional term, 1. - T. D. Noe, May 27 2008

Examples

			E.g. 393^2 - 1 = 28^2 + 392^2 only.
		

Crossrefs

Programs

  • Mathematica
    twoSquaresQ[ n_] := (r = Reduce [0 < a <= b && n^2 - 1 == a^2 + b^2, {a, b}, Integers]; Head[r] === And); Select[ Range[21000], twoSquaresQ] (* Jean-François Alcover, Oct 10 2011 *)

Extensions

More terms from James Sellers

A124980 Smallest strictly positive number decomposable in n different ways as a sum of two squares.

Original entry on oeis.org

1, 25, 325, 1105, 4225, 5525, 203125, 27625, 71825, 138125, 2640625, 160225, 17850625, 1221025, 1795625, 801125, 1650390625, 2082925, 49591064453125, 4005625, 44890625, 2158203125, 30525625, 5928325, 303460625, 53955078125, 35409725, 100140625
Offset: 1

Views

Author

Artur Jasinski, Nov 15 2006

Keywords

Comments

The number must be strictly positive, but one of the squares may be zero, as we see from a(1) = 1 = 1^2 + 0^2 and a(2) = 25 = 3^2 + 4^2 = 5^0 + 0^2. - M. F. Hasler, Jul 07 2024

Examples

			a(3) = 325 is decomposable in 3 ways: 15^2 + 10^2 = 17^2 + 6^2 = 18^2 + 1^2.
		

Crossrefs

See A016032, A000446 and A093195 for other versions.

Programs

  • PARI
    A124980(n)={for(a=1, oo, A000161(a)==n && return(a))} \\ R. J. Mathar, Nov 29 2006, edited by M. F. Hasler, Jul 07 2024
    
  • PARI
    PD(n, L=n, D=Vecrev(divisors(n)[^1])) = { if(n>1, concat(vector(#D, i, if(D[i] > L, [], D[i] < n, [concat(D[i], P) | P <- PD(n/D[i], D[i])], [[n]]))), [[]])}
    apply( {A124980(n)=vecmin([prod(i=1, #a, A002144(i)^(a[i]-1)) | a<-concat([PD(n*2,n), PD(n*2-1)])])}, [1..44]) \\ M. F. Hasler, Jul 07 2024
    
  • Python
    from sympy import divisors, isprime, prod
    def PD(n, L=None): return [[]] if n==1 else [
        [d]+P for d in divisors(n)[:0:-1] if d <= (L or n) for P in PD(n//d, d)]
    A2144=lambda upto=999: filter(isprime, range(5, upto, 4))
    def A124980(n):
        return min(prod(a**(f-1) for a,f in zip(A2144(), P))
                   for P in PD(n*2, n)+PD(n*2-1)) # M. F. Hasler, Jul 07 2024

Formula

a(n) = A000446(n), n > 1. - R. J. Mathar, Jun 15 2008
a(n) = min(A018782(2n-1), A018782(2n)).
a(n) = min { k > 0 | A000161(k) = n }. - M. F. Hasler, Jul 07 2024

Extensions

More terms from R. J. Mathar, Nov 29 2006
Edited and extended by Ray Chandler, Jan 07 2012

A143574 Sum of all distinct squares occurring when partitioning n into two squares.

Original entry on oeis.org

0, 1, 1, 0, 4, 5, 0, 0, 4, 9, 10, 0, 0, 13, 0, 0, 16, 17, 9, 0, 20, 0, 0, 0, 0, 50, 26, 0, 0, 29, 0, 0, 16, 0, 34, 0, 36, 37, 0, 0, 40, 41, 0, 0, 0, 45, 0, 0, 0, 49, 75, 0, 52, 53, 0, 0, 0, 0, 58, 0, 0, 61, 0, 0, 64, 130, 0, 0, 68, 0, 0, 0, 36, 73, 74, 0, 0, 0, 0, 0, 80, 81, 82, 0, 0, 170, 0, 0, 0
Offset: 0

Views

Author

Reinhard Zumkeller, Aug 24 2008

Keywords

Comments

For n > 0: a(n) = 0 iff A000161(n) = 0: a(A022544(n)) = 0;
A143575 gives numbers m such that a(m) = m.

Examples

			A000161(25)=#{5^2+0^2,4^2+3^2}=2: a(25)=25+0+16+9=50;
A000161(26)=#{5^2+1^2}=1: a(16)=25+1=26;
A000161(49)=#{7^2+0^2}=1: a(49)=49+0=49;
A000161(50)=#{7^2+1^2,5^2+5^2}=2: a(50)=49+1+25=75;
A000161(2600)=#{50^2+10^2,46^2+22^2,38^2+34^2}=3: a(2600)=2500+100+2116+484+1444+1156=7800;
A000161(2601)=#{51^2+0^2,45^2+24^2}=2: a(2601)=2601+0+12025+576=5202;
A000161(2602)=#{51^2+1^2}=1: a(2602)=2601+1=2602.
		

Crossrefs

Programs

  • PARI
    a(n) = sum(k=1, n, if (issquare(k) && issquare(n-k), k)); \\ Michel Marcus, May 16 2023
  • Python
    from sympy import divisors
    from sympy.solvers.diophantine.diophantine import cornacchia
    def A143574(n):
        c = 0
        for d in divisors(n):
            if (k:=d**2)>n:
                break
            q, r = divmod(n,k)
            if not r:
                c += sum(k*(a[0]**2+(a[1]**2 if a[0]!=a[1] else 0)) for a in cornacchia(1,1,q) or [])
        return c # Chai Wah Wu, May 15 2023
    

Formula

a(n) = Sum_{k=1..n} k*A010052(k)*A010052(n-k). [Reinhard Zumkeller, Sep 27 2008]

A007511 a(n) is the smallest number greater than a(n-1) that is expressible as the sum of two squares in more ways than a(n-1).

Original entry on oeis.org

2, 50, 325, 1105, 5525, 27625, 71825, 138125, 160225, 801125, 2082925, 4005625, 5928325, 29641625, 77068225, 148208125, 243061325, 1215306625, 3159797225, 6076533125, 12882250225, 53716552825, 64411251125, 167469252925, 322056255625, 785817263725
Offset: 1

Views

Author

Gabriel Cunningham (gcasey(AT)mit.edu), Feb 29 2004

Keywords

Comments

Sequence provides the locations of records in A025426 (nonzero squares), rather than in A000161 (definition of squares includes zeros). - R. J. Mathar, Jun 06 2007

Crossrefs

Cf. A048610.

Extensions

a(12)-a(18) from Donovan Johnson, Sep 03 2008
a(19)-a(24) from Donovan Johnson, Jul 01 2009
a(25)-a(26) from Donovan Johnson, Aug 30 2011

A046711 From the Bruck-Ryser theorem: numbers n == 1 or 2 (mod 4) which are also the sum of 2 squares.

Original entry on oeis.org

1, 2, 5, 9, 10, 13, 17, 18, 25, 26, 29, 34, 37, 41, 45, 49, 50, 53, 58, 61, 65, 73, 74, 81, 82, 85, 89, 90, 97, 98, 101, 106, 109, 113, 117, 121, 122, 125, 130, 137, 145, 146, 149, 153, 157, 162, 169, 170, 173, 178, 181, 185, 193, 194, 197, 202, 205, 218, 221, 225
Offset: 1

Views

Author

Keywords

Comments

Intersection of A001481 and A042963; A000161(a(n)) > 0. - Reinhard Zumkeller, Feb 14 2012

References

  • M. Hall, Jr., Combinatorial Theory, Theorem 12.3.2.

Crossrefs

Programs

  • Haskell
    a046711 n = a046711_list !! (n-1)
    a046711_list = [x | x <- a042963_list, a000161 x > 0]
    -- Reinhard Zumkeller, Aug 16 2011
    
  • Mathematica
    max = 225; Flatten[ Table[ a^2 + b^2, {a, 0, Sqrt[max]}, {b, a, Sqrt[max - a^2]}], 1] // Union // Select[#, (1 <= Mod[#, 4] <= 2)& ]& (* Jean-François Alcover, Sep 13 2012 *)
    With[{max=15},Select[Select[Total/@Tuples[Range[0,max]^2,2], MemberQ[ {1,2}, Mod[ #,4]]&]//Union,#<=max^2&]] (* Harvey P. Dale, Jan 14 2017 *)
  • Python
    from itertools import count, islice
    from sympy import factorint
    def A046711_gen(): # generator of terms
        return filter(lambda n:0 < n & 3 < 3 and all(p & 3 != 3 or e & 1 == 0 for p, e in factorint(n).items()),count(0))
    A046711_list = list(islice(A046711_gen(),30)) # Chai Wah Wu, Jun 28 2022

Extensions

More terms from James Sellers

A050798 Numbers n such that m = n^2 + 1 is expressible as the sum of two nonzero squares in exactly two ways.

Original entry on oeis.org

1, 7, 8, 12, 13, 17, 21, 22, 23, 27, 28, 30, 31, 33, 34, 37, 41, 42, 44, 46, 48, 50, 52, 53, 55, 58, 60, 62, 63, 64, 67, 75, 76, 77, 78, 80, 81, 86, 87, 88, 89, 91, 92, 96, 97, 100, 102, 103, 104, 105, 106, 108, 109, 111, 113, 114, 115, 119, 125, 127, 129, 135, 136
Offset: 1

Views

Author

Patrick De Geest, Sep 15 1999

Keywords

Comments

Of course m = n^2 + 1 is the sum of two squares, by definition. Here there should be just one other way to write m as a different sum of two squares.
Let p and q be primes of the form 1+4k. Then n^2+1 must be pq or 2pq. - T. D. Noe, May 27 2008

Examples

			E.g., 111^2 + 1 = 21^2 + 109^2 only.
		

Crossrefs

Programs

  • Mathematica
    ok[1] = True; ok[n_] := Length[ {ToRules[ Reduce[ 1 < x <= y && n^2 + 1 == x^2 + y^2, {x, y}, Integers] ] } ] == 1; Select[ Range[136], ok] (* Jean-François Alcover, Feb 16 2012 *)

Extensions

Better definition from T. D. Noe, May 27 2008
Previous Showing 21-30 of 65 results. Next