login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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:
seq(a(n), n=1..102); # Alois P. Heinz, Apr 08 2022
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
Sequence in context: A105586 A202022 A136522 * A188641 A086299 A131364
KEYWORD
sign,base,easy
AUTHOR
Jonathan Berliner, Apr 06 2022
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 20:08 EDT 2024. Contains 371963 sequences. (Running on oeis4.)