OFFSET
1,1
COMMENTS
The sequence begins with x(0) = n and continues by adding or subtracting the digitsum. When the digitsum(x(i-1)) is even, x(i) = x(i-1) + digitsum(x(i-1)), otherwise x(i) = x(i-1) - digitsum(x(i-1)).
LINKS
Anthony Sand, Table of n, a(n) for n = 1..1000
FORMULA
x(i) = x(i-1) + digitsum(x(i-1)) * (1 - (digitsum(x(i-1)) mod 2) * 2).
EXAMPLE
digitsum(99) = 18, 18 is even, so 99 + 18 = 117. digitsum(117) = 9, 9 is odd, so 177 - 9 = 108. 108 - 9 = 99, hence 99 belongs to sequence.
108 - 9 = 99, 99 + 18 = 117, 117 - 9 = 108, hence 108 is in the sequence.
117 - 9 = 108. 108 - 9 = 99. 99 + 18 = 117.
198 + 18 = 216. 216 - 9 = 207. 207 - 9 = 198.
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Anthony Sand, Jun 02 2014
STATUS
approved