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...any number that doesn't, isn't".

He discussed this rule when helping Martha Jones answer 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 no longer taught recreational mathematics. (TV: 42)