OFFSET
1,1
COMMENTS
Based on empirical observations, it can be noted that the difference between consecutive terms is usually 99. However, this breaks down when the hundreds digit is 9, in which case the difference between consecutive terms is 9. This changes back, however.
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
Brilliant.org, Those are some nifty numbers
Australian Mathematics Olympiad, Question 2, 2015, p. 84.
EXAMPLE
If k=90, then k-s(k)=81. If k=100, then k-s(k)=99. This is an increasing function, so k-s(k)=90 is unachievable.
MATHEMATICA
okQ[n_] := Catch[ Do[ If[ x- Total@ IntegerDigits@ x == n, Throw@ False], {x, n, n+ 9 IntegerLength[n]}]; True]; Select[9 Range[1000], okQ[#] &] (* Giovanni Resta, Feb 27 2017 *)
PROG
(Python)
from math import ceil
def a(n): #Outputs all numbers less than n which are in the sequence
def s(n):
r = 0
while n:
r, n = r + n% 10, n//10
return r
mult9=[]
if n%9==0:
for x in range(1, ceil(n/9)+1):
mult9.append(9*x)
else:
for x in range(1, ceil(n/9)):
mult9.append(9*x)
for y in range(1, ceil(n/10)+1):
mult9.remove(10*y-s(10*y))
return mult9
(PARI) is(n)=for(k=n, n+9*#Str(n)+9, if(k-sumdigits(k)==n, return(0))); n%9==0 \\ Charles R Greathouse IV, Feb 27 2017
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Sharvil Kesarwani, Feb 16 2017
STATUS
approved