|
|
A352871
|
|
a(n) is the number of iterations, starting with x = n, which can be made of x -> x/sumdigits(x) with x remaining an integer, or -1 if x remains an integer through infinitely many iterations.
|
|
0
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, 0, 0, 0, 0, -1, 0, -1, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, -1, 0, -1, 0, 0, -1, 0, 0, -1, 0, -1, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1
|
|
COMMENTS
|
sumdigits(x) = A007953(x) is the sum of the decimal digits of x.
A Harshad number (A005349) is divisible by the sum of its digits and the iterations here step through Harshad numbers until reaching a non-Harshad number.
a(102) = 1 is the first term that is neither 0 nor -1.
a(1008) is the first term whose value is 2.
a(10080) is the first term whose value is 3.
a(100800) is the first term whose value is 4.
a(1008000) is the first term whose value is 5.
|
|
REFERENCES
|
D. R. Kaprekar, Multidigital Numbers, Scripta Mathematica 21 (1955), 27.
|
|
LINKS
|
|
|
EXAMPLE
|
13000/(1+3+0+0+0) = 3250, and 3250/(3+2+5+0) = 325, but 325/(3+2+5) is not an integer, so a(13000) = 2.
|
|
MAPLE
|
a:= proc(n) option remember;
`if`(irem(n, add(i, i=convert(n, base, 10)), 'm')>0, 0,
`if`(n=m, -1, (t-> `if`(t<0, t, t+1))(a(m))))
end:
|
|
PROG
|
(Python)
def sumdigits(n: int) -> int:
return sum(map(int, str(n)))
def a(n: int) -> int:
i = 0
while True:
denom = sumdigits(n)
if denom == 1:
i = -1
break
elif n % denom == 0:
i = i + 1
n = n // denom
else:
break
return i
|
|
CROSSREFS
|
|
|
KEYWORD
|
sign,base,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|