# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a133388 Showing 1-1 of 1 %I A133388 #38 Sep 24 2024 02:11:56 %S A133388 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, %T A133388 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, %U A133388 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 %N A133388 Largest integer m such that n-m^2 is a square, or 0 if no such m exists. %C A133388 The sequence could be extended to a(0) = 0. %C A133388 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. %H A133388 Alois P. Heinz, Table of n, a(n) for n = 1..20000 %F A133388 a(n) = max( sup { max(a,b) | a^2+b^2 = n ; a,b in Z }, 0 ) %F A133388 a(A022544(j))=0, j>0. - _R. J. Mathar_, Jun 17 2009 %F A133388 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 %e A133388 a(3) = 0 since 3 cannot be written as sum of 2 perfect squares; %e A133388 a(5) = 2 since 5 = 2^2 + 1^2. %p A133388 a:= proc(n) local t, d; %p A133388 for t from 0 do d:= n-t^2; %p A133388 if d<0 then break elif issqr(d) then return isqrt(d) fi %p A133388 od; 0 %p A133388 end: %p A133388 seq(a(n), n=1..100); # _Alois P. Heinz_, May 14 2015 %t A133388 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]; %t A133388 Table[a[n], {n, 1, 100}] (* _Jean-François Alcover_, May 18 2018, after _Alois P. Heinz_ *) %o A133388 (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. (If PARI version 2.12.x returns an error, append [1] to qfbsolve(...) above. - _M. F. Hasler_, Dec 12 2019) %o A133388 apply( A133388=n->if(n=sum2sqr(n),vecmax(Mat(n~))), [1..50]) \\ This sequence: maximum %o A133388 (Python) %o A133388 from sympy.solvers.diophantine.diophantine import diop_DN %o A133388 def A133388(n): return max((a for a, b in diop_DN(-1,n)),default=0) # _Chai Wah Wu_, Sep 08 2022 %Y A133388 Cf. A000161, A001481. %K A133388 nonn %O A133388 1,4 %A A133388 _M. F. Hasler_, Nov 23 2007 # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE