# Suppose N is any positive integer. Add the digits of N to obtain a smaller integer.

Suppose N is any positive integer. Add the digits of N to obtain a smaller integer. Repeat this process of digit-addition till you get a single digit number n. Find the number of positive integers N ≤ 1000, such that the final single-digit number n is equal to 5.

Let $s(n)$ be the sum of digits function. Then $n\equiv s(n)\pmod{9}$, and by induction $$n\equiv s(\cdots(s(n))\cdots)\pmod{9}.$$ Since the last obtained number is $5$ then it equivalent to find the number of positive integers which have remainder $5$ modulo $9$, i.e., $\lfloor 1000/9\rfloor=111$.
• $999$ has not remainder $5$ when it is divided by $9$; the last one is $995$.. – Paolo Leonetti Feb 1 '17 at 17:38