OFFSET
1,2
COMMENTS
Numbers divisible by the sum of their digits are called Niven (or Harshad, or harshad) numbers (A007602).
LINKS
FORMULA
a(n) = n iff n belongs to A005349.
EXAMPLE
For n = 32:
- the divisors of 32 are 1, 2, 4, 8, 16 and 32,
- 8 is divisible by 8 whereas 16 is not divisible by 1+6 and 32 is not divisible by 3+2,
- so a(32) = 8.
MATHEMATICA
Table[Max[Select[Divisors[n], Mod[#, Total[IntegerDigits[#]]]==0&]], {n, 80}] (* Harvey P. Dale, Sep 04 2023 *)
PROG
(PARI) a(n) = fordiv (n, d, my (t=n/d); if (t%sumdigits(t)==0, return (t)))
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Jan 24 2023
STATUS
approved