login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A133388 Largest integer m such that n-m^2 is a square, or 0 if no such m exists. 13
1, 1, 0, 2, 2, 0, 0, 2, 3, 3, 0, 0, 3, 0, 0, 4, 4, 3, 0, 4, 0, 0, 0, 0, 5, 5, 0, 0, 5, 0, 0, 4, 0, 5, 0, 6, 6, 0, 0, 6, 5, 0, 0, 0, 6, 0, 0, 0, 7, 7, 0, 6, 7, 0, 0, 0, 0, 7, 0, 0, 6, 0, 0, 8, 8, 0, 0, 8, 0, 0, 0, 6, 8, 7, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, 9, 0, 0, 0, 8, 9, 0, 0, 0, 0, 0, 0, 9, 7, 0, 10 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,4

COMMENTS

The sequence could be extended to a(0) = 0.

We could have defined a(n) = -1 instead of 0 if n is not sum of two squares, and then include unambiguously a(0) = 0. At present, a(n) = 0 <=> A000161(n) = 0.

LINKS

Alois P. Heinz, Table of n, a(n) for n = 1..20000

FORMULA

a(n) = max( sup { max(a,b) | a^2+b^2 = n ; a,b in Z }, 0 )

a(A022544(j))=0, j>0. - R. J. Mathar, Jun 17 2009

a(n^2) = a(n^2 + 1) = n, for all n. Conversely, whenever a(n) = a(n+1), then n = k^2. - M. F. Hasler, Sep 02 2018

EXAMPLE

a(3) = 0 since 3 cannot be written as sum of 2 perfect squares;

a(5) = 2 since 5 = 2^2 + 1^2.

MAPLE

a:= proc(n) local t, d;

      for t from 0 do d:= n-t^2;

        if d<0 then break elif issqr(d) then return isqrt(d) fi

      od; 0

    end:

seq(a(n), n=1..100);  # Alois P. Heinz, May 14 2015

MATHEMATICA

a[n_] := Module[{m, d, s}, For[m = 0, True, m++, d = n - m^2; If[d < 0, Break[], s = Sqrt[d]; If[IntegerQ[s], Return[s]]]]; 0];

Table[a[n], {n, 1, 100}] (* Jean-Fran├žois Alcover, May 18 2018, after Alois P. Heinz *) *)

PROG

(PARI) sum2sqr(n)={ if(n>1, my(L=List(), f, p=1); for(i=1, matsize(f=factor(n))[1], if(f[i, 1]%4==1, listput(L, [qfbsolve(Qfb(1, 0, 1), f[i, 1])*[1, I]~, f[i, 2]] ), /*elseif*/ f[i, 1]==2, p = (1+I)^f[i, 2], /*elseif*/ bittest(f[i, 2], 0), return([]), /*else*/ p *= f[i, 1]^(f[i, 2]\2))); L=apply(s->vector(s[2]+1, j, s[1]^(s[2]+1-j)*conj(s[1])^(j-1)), L); my(S=List()); forvec(T=vector(#L, i, [1, #L[i]]), listput(S, prod( j=1, #T, L[j][T[j]] ))); Set(apply(f->vecsort(abs([real(f), imag(f)])), Set(S)*p)), if(n<0, [], [[0, n]]))} \\ updated by M. F. Hasler, May 12 2018

apply( A133388=n->if(n=sum2sqr(n), vecmax(Mat(n~))), [1..50]) \\ This sequence: maximum

CROSSREFS

Cf. A000161, A001481.

Sequence in context: A031124 A063695 A081417 * A282516 A158092 A145264

Adjacent sequences:  A133385 A133386 A133387 * A133389 A133390 A133391

KEYWORD

nonn

AUTHOR

M. F. Hasler, Nov 23 2007

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified October 23 23:51 EDT 2019. Contains 328379 sequences. (Running on oeis4.)