OFFSET
1,10
COMMENTS
a(102) = 34 is the least integer without itself or a power of 10 as a root.
LINKS
James Carruthers, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Harshad Numbers.
Wikipedia, Harshad number.
EXAMPLE
a(20) = 10 since 20/(2+0) = 10 and 10 loops to itself.
MATHEMATICA
a[n_] := NestWhile[# / DigitSum[#] &, n, DigitSum[#] > 1 && Divisible[#, DigitSum[#]] &]; Array[a, 100] (* Amiram Eldar, Sep 27 2025 *)
PROG
(Python)
def a(n):
while n % (digsum:=sum([int(d) for d in str(n)])) == 0 and digsum != 1:
n//=digsum
return n
print([a(n) for n in range(1, 80)])
(PARI) a(n) = {my(r=n, s); while((s=sumdigits(r)) != 1 && r%s==0, r/=s); r} \\ Andrew Howroyd, Sep 26 2025
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
James Carruthers, Sep 25 2025
STATUS
approved
