Here is a Mathematica snippit to count the number of Happy Numbers up to 1000:

Length[Select[Range[1000], 
FixedPoint[Total[IntegerDigits[#]^2] &, #, 10] == 1 &]]