Happy number

According to the Tenth Doctor, a happy number  was "any number that reduces to one when you take the sum of the square of its digits and continue iterating it until it yields 1 is a happy number, any number that doesn't, isn't".

He discussed this rule when helping Martha Jones answers a quiz question about a sequence of happy prime numbers, numbers which are both happy and prime. He momentarily criticised her and the other humans present for their lack of understanding, expressing concern schools don't teach mathematics properly anymore. (TV: 42)