OFFSET
1,11
COMMENTS
Since nonzero numbers may not have leading zeros, we indicate their presence by negating the number.
For use in A359142, we also define a(n) for improper decimal numbers n with leading zeros by following exactly the same steps. To get a(073), for example, we append the digit sum 10, and delete the 0's from 07310, getting a(073) = 731. To get a(074), we append 11, getting 07411, so a(074) = -7411.
The sequence of n such that a(n) < 0 begins (109, 1009, 1018, 1019, 1027, 1028, 1029, 1036, ...): see A359144. - M. F. Hasler, Feb 01 2023
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
Eric Angelini, Does this iteration end? (Sum and erase), Personal blog "Cinquante Signes", blogspot.com, Jul 26 2022.
Eric Angelini, Does this iteration end? (Sum and erase), Personal blog "Cinquante Signes", blogspot.com, Jul 26 2022. [Cached copy, pdf file, with permission]
Hans Havermann, Cycles in Eric Angelini's sum-and-erase, Personal blog "Glad Hobo Express", blogspot.com, Jul 28 2022.
EXAMPLE
Examples:
n.....s......t....u.....a(n)
1.....1.....11....0......0
2.....2.....22....0......0
.....
9.....9.....99....0......0
10....1....101....0......0
11....2....112..112....112
12....3....123..123....123
.....
100...1...1001...00......0
101...2...1012.1012...1012
102...3...1023.1023...1023
.....
109..10..10910..090....-90
.....
MATHEMATICA
A359142[n_]:= Module[{d=IntegerDigits[n], s, u}, If[MemberQ[s=IntegerDigits[Total[d]], First[u=Join[d, s]]], u=DeleteCases[u, First[u]]]; If[u=={}||First[u]==0, -1, 1]FromDigits[u]]; Array[A359142, 100] (* Paolo Xausa, Oct 11 2023 *)
PROG
(PARI) A359142(n) = { my(d=digits(n), s=digits(vecsum(d))); n>0 || d=concat(0, d); n=concat(d, s); setsearch(Set(s), d[1]) && n=select(c->c!=d[1], n); if(n && !n[1], -fromdigits(n), fromdigits(n)) }
apply(A359142, [0..99]) \\ M. F. Hasler, Feb 01 2023
(Python)
def a(n):
n = str(-n) if isinstance(n, int) and n < 0 else str(n)
s = str(sum(map(int, n)))
t = n + s
u = t.replace(t[0], "") if t[0] in s else t
return 0 if u == "" else (-int(u) if u[0] == "0" else int(u))
print([a(n) for n in range(1, 59)]) # Michael S. Branicky, Feb 01 2023
CROSSREFS
KEYWORD
sign,base
AUTHOR
EXTENSIONS
More terms from M. F. Hasler, Feb 01 2023
STATUS
approved