A004431 Numbers that are the sum of 2 distinct nonzero squares.
5, 10, 13, 17, 20, 25, 26, 29, 34, 37, 40, 41, 45, 50, 52, 53, 58, 61, 65, 68, 73, 74, 80, 82, 85, 89, 90, 97, 100, 101, 104, 106, 109, 113, 116, 117, 122, 125, 130, 136, 137, 145, 146, 148, 149, 153, 157, 160, 164, 169, 170, 173, 178, 180, 181, 185, 193, 194, 197
Offset: 1
Keywords
Examples
53 = 7^2 + 2^2, so 53 is in the sequence.
Links
Crossrefs
Programs
-
Haskell
import Data.List (findIndices) a004431 n = a004431_list !! (n-1) a004431_list = findIndices (> 1) a063725_list -- Reinhard Zumkeller, Aug 16 2011
-
Maple
isA004431 := proc(n) local a,b ; for a from 2 do if a^2>= n then return false; end if; b := n -a^2 ; if b < 1 then return false ; end if; if issqr(b) then if ( sqrt(b) <> a ) then return true; end if; end if; end do: return false; end proc: A004431 := proc(n) option remember ; local a; if n = 1 then 5; else for a from procname(n-1)+1 do if isA004431(a) then return a; end if; end do: end if; end proc: # R. J. Mathar, Jan 29 2013
-
Mathematica
A004431 = {}; Do[a = 2 m * n; b = m^2 - n^2; c = m^2 + n^2; AppendTo[A004431, c], {m, 100}, {n, m - 1}]; Take[Union@A004431, 63] (* Robert G. Wilson v, May 02 2009 *) Select[Range@ 200, Length[PowersRepresentations[#, 2, 2] /. {{0, } -> Nothing, {a, b_} /; a == b -> Nothing}] > 0 &] (* Michael De Vlieger, Mar 24 2016 *)
-
PARI
select( isA004431(n)={n>1 && vecmin((n=factor(n)%4)[,1])==1 && ![f[1]>2 && f[2]%2 | f<-n~]}, [1..199]) \\ M. F. Hasler, Feb 06 2009, updated Nov 24 2019
-
PARI
is(n)=if(n<5, return(0)); my(f=factor(n)%4); if(vecmin(f[, 1])>1, return(0)); for(i=1, #f[, 1], if(f[i, 1]==3 && f[i, 2]%2, return(0))); 1 for(n=1, 1e3, if(is(n), print1(n, ", "))) \\ Altug Alkan, Dec 06 2015
-
PARI
upto(n) = {my(res = List(), s); forstep(i=1, sqrtint(n), 2, forstep(j = 2, sqrtint(n - i^2), 2, listput(res, i^2 + j^2))); s = #res; for(i = 1, s, t = res[i]; for(e = 1, logint(n \ res[i], 2), listput(res, t<<=1))); listsort(res, 1); res} \\ David A. Corneth, Oct 04 2017
-
Python
def aupto(limit): s = [i*i for i in range(1, int(limit**.5)+2) if i*i < limit] s2 = set(a+b for i, a in enumerate(s) for b in s[i+1:] if a+b <= limit) return sorted(s2) print(aupto(197)) # Michael S. Branicky, May 10 2021
Comments