OFFSET
1,2
LINKS
Amiram Eldar, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Digit.
EXAMPLE
For k = 2196, 2^2 + 1^2 + 9^2 + 6^2 = 122, 2 + 1 + 9 + 6 = 18, and 2196 = 18*122 so it is divisible by both 18 and 122.
MAPLE
with(numtheory):for n from 1 to 1000000 do:l:=evalf(floor(ilog10(n))+1):n0:=n:s1:=0:s2:=0:for m from 1 to l do:q:=n0:u:=irem(q, 10):v:=iquo(q, 10):n0:=v :s1:=s1+u:s2:=s2+u^2:od:if irem(n, s1)=0 and irem(n, s2)=0 then print(n):else fi:od:
MATHEMATICA
Select[Range[2220], Divisible[#, Plus @@ (d = IntegerDigits[#])] && Divisible[#, Plus @@ (d^2)] &] (* Amiram Eldar, Mar 04 2023 *)
PROG
(PARI) sd2(n) = my(d=digits(n)); sum(i=1, #d, d[i]^2);
isok(n) = !(n % sumdigits(n)) && !(n % sd2(n)); \\ Michel Marcus, Dec 21 2014
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Michel Lagneau, Apr 05 2010
STATUS
approved