Square digit sum sequences puzzle An interesting problem from Cambridge University press. It is supposed to be solved by programming, but I wondered if there was any way to solve it mathematically.
Here is the problem:
A student has a book containing 411 pages.
She read a certain number of pages on the first day and created a rule to work out how many pages she had to read on each succeeding day.
She decided that the number of pages to be read on the next day should be equal to the square of the sum of the digits of the page she ended at.
For example, if she ended on page 36, then she should read 81 pages on the next day as this is the square of 6 + 3.
She found that on the sixth day, the number of pages she had set herself to read took her exactly to the final page of the book.
How many pages did she read each day?
 A: Whatever you do, some case analysis is going to be required, as a function that is explicitly dependent on the digits of a number is not usually mathematically nice to work with.  However, since our function involves the sum of the digits, a quantity that only depends on our number modulo 9, we can at least save a little work.
Let $s(n)$ be the sum of the digits in the natural number $n$.  If $f(n)$ is the function that tells us what page we end on a day of reading if we start on page $n$, we can write $f(n)=n+s(n)^2.$  If we write $g^{(k)}$ for the $k$-fold composition of $g$ with itself (i.e., $g\circ g \circ g \circ \cdots \circ g$, with $k$ $g$'s), then we are trying to solve $f^{(5)}(n)=411.$
Since $s(n) \equiv n \pmod 9$, we have $f(n)\equiv n^2+n \pmod 9$.  (Note, there are not nice formulas for $s(n)$ modulo most numbers, 9 is special).  Using this, we can compute what composing $f$ multiple times does, at least mod 9.  Under $f$, we have the following chains:
$$\{1,4,7\}\mapsto 2 \mapsto 6\mapsto 6\mapsto \cdots, \qquad 8\mapsto 0 \mapsto 0 \mapsto \cdots, \qquad 5\mapsto 3 \mapsto 3 \mapsto \cdots$$
For example, if on the first day we started with a page congruent to 5 mod 9, every day afterwards we would be on a page congruent to 3 mod 9.
Since $411\equiv 6 \pmod 9$, we know we are in the case of the first cycle: we must start on a page congruent to either 1, 2, 4, 6, or 7 mod 9, and from the third day onward, we will start on a page congruent to 6 mod 9.
Using this, we will try to work backwards.  If $f^{(5)}(n)=f(f^{(4)}(n))=411$, what possible values can we have for $f^{(4)}(n)$.  We know it is a three digit number (whose first digit is at most 4) congruent to $6$ mod 9.  The sum of the digits must therefore be either $6$ or $15$ (as $9+9+4<24$), and therefore, if $f(y)=411$ with $y\equiv 6 \pmod 9$, either $y+6^2=411$ or $y+15^2=411$.  However, in the first case, $y=375$, but the sum of the digits in $375$ is not $6$, and therefore we have $y=411-15^2=186$.  We check, of course, that the sum of the digits in $186$ is indeed equal to $15$.  Now, we've reduced the problem to solving $f^{(4)}(n)=186$.
Again, as before, we have that $f^{(3)}(n)\equiv 6 \pmod 9$, and therefore has a digit sum of either 6 or 15, making it either $186-6^2=150$ or $186-15^2$, which is negative.  Therefore, $f^{(3)}(n)=150$.
We also know that $f^{(2)}(n)\equiv 6 \pmod 9$, and for the same reasoning as before, we conclude that $f^{(2)}(n)=150-6^2=114$.
Unfortunately, things get more complicated here, as $f(n)$ could be congruent to either $2$ or $6$ mod $9$.  Since 114<11^2, we know the digit sum of $f(n)$ is at most 10, and hence is either 2 (in which case $f(n)=114-2^2=110$, which does have a digit sum of $2$), or 6 (in which case $f(n)=114-6^2=78$, which does not have a digit sum of $6$ and can be ruled out).  Therefore, $f(n)=110$.   
Now, things get even messier.  We have that $n$ is congruent to either $1, 4,$ or $7$, modulo 9, and we have to check each case individually to see what happens.  Again, the digit sum of $n$ is less than 11, which means $s(n)\in \{1, 4, 7, 10\}$, and so  $n=110-s(n)^2$ is one of $109, 94, 61,$ or $10$, whose corresponding digit sums are 10, 13, 7, and 1 respectively.  Of these, we only have one matchup: $n=61.$
A: I found it, it's $61$.
First day 61.
Next day(2): $61+7^2=110$
Next day(3): $110+2^2=114$
Next day(4): $114+6^2=150$
Next day(5): $150+6^2=186$
Next day(6): $186+15^2=411$

Here's some data
P.S. I used the code to even print latex!
The number of pages read on first day that end up to 411 pages, not necessarily in 6 days:
$$\begin{array}{c|c}
\text{pages read $\\$on first day}&\text{days required to$\\$ read exactly 411 pages}\\\hline
13&5\\
16&4\\
29&4\\
\huge \color{red}{61}&\huge \color{red}{6}\\
65&3\\
110&5\\
114&4\\
150&3\\
186&2\\
190&3\\
241&3\\
290&2\\
\end{array}$$

Code
import java.util.*;
import java.lang.*;
import java.io.*;

class ADG {
  public static void main(String[] args) throws java.lang.Exception {
    for (int firstpage = 1; firstpage <= 411; firstpage++) {
      int sum = firstpage;
      int day = 1;
      do {
        sum += squareofroot(sum);
        day++;
        if (sum == 411) {
          System.out.println(firstpage + "&" + day + "\\\\");
          break;
        }
      } while (sum <= 411);
    }
  }
  public static int squareofroot(int pnum) {
    int root = 0;
    int j = 0;
    do {
      root += pnum % 10;
      pnum = pnum / 10;
      j = j + 1;
    } while (pnum != 0);
    return (root * root);
  }

}

