login
Numbers which are sums of squares of some subset of divisors.
4

%I #15 May 27 2024 09:17:30

%S 1,4,9,16,20,25,30,36,49,64,80,81,90,100,120,121,126,130,144,150,169,

%T 180,195,196,210,225,252,256,264,270,272,280,289,294,300,315,320,324,

%U 330,336,350,360,361,378,390,396,400,414,420,441,450,468,480,484,500

%N Numbers which are sums of squares of some subset of divisors.

%C If m is in the sequence then so is m*k^2 for k >= 1. - _David A. Corneth_, Jan 22 2024

%H David A. Corneth, <a href="/A066213/b066213.txt">Table of n, a(n) for n = 1..10000</a>

%H David A. Corneth, <a href="/A066213/a066213.gp.txt">PARI program</a>

%e 20 is in the list since 20 = 2^2 + 4^2 and 2 and 4 are divisors of 20

%p isA066213 := proc(n)

%p local S,els;

%p S:=subsets(numtheory[divisors](n));

%p while not S[finished] do

%p els:=S[nextvalue]() ;

%p if add(d^2,d=els) = n then

%p return true ;

%p end if ;

%p end do;

%p false

%p end proc:

%p for n from 1 do

%p if isA066213(n) then

%p print(n) ;

%p end if;

%p end do: # _R. J. Mathar_, Oct 09 2023

%t okQ[k_] := AnyTrue[Subsets[Select[Divisors[k]^2, # <= k&]], Total[#]==k&];

%t Reap[For[k = 1, k <= 5000, k++, If[okQ[k], Print[k]; Sow[k]]]][[2, 1]] (* _Jean-François Alcover_, May 27 2024 *)

%o (PARI) \\ See PARI link

%Y Cf. A005835, A066214, A066215, A066216.

%K nonn

%O 1,2

%A _Erich Friedman_, Dec 17 2001

%E Offset 1 from _David A. Corneth_, Jan 22 2024