# Is Sum of digits related with Sum of Squares of its digit

In a specified range, I want to get the number of numbers, in which sum of its digits and sum of squares of its digits are prime number. For an example from 2 to 12, there are only 2 numbers which has both its sum of digit and sum of square of its digit are prime number. These two numbers are 11 and 12. In 12, sum of its digit 1+2=3 and sum of square of its digit 1+4=5 are prime numbers.
Although the question is related to programming but it seems that there must be some number theory trick which can solve it quickly. I am very keen to know that trick if at all exists. Thank you.

-
For your grammatical edification: "it's" is NOT possessive; "it's" is short for "it is", which is a complete sentence. "Its" is possessive, and should be used in every place you used "it's" here. (I could just edit, but "teach a man to fish...") – The Chaz 2.0 Apr 15 '12 at 18:18
@TheChaz: Thank you for the information. i have corrected it. If anywhere you find any grammatical mistakes, please let me know. :) – Ravi Joshi Apr 15 '12 at 18:41
The other two most common homophone mistakes are you're/your and they're/their/there. – The Chaz 2.0 Apr 15 '12 at 20:35
Discussed as a programming problem at codereview.stackexchange.com/questions/8319/… – Gerry Myerson Apr 16 '12 at 0:25

Analytic number theory could produce a heuristic for approximately how many numbers up to $x$ satisfy your two conditions (that is, a predicted asymptotic formula), but I doubt it can be proved. Even if it could, it would only give the answer approximately, not exactly as you seem to want. So I don't think there's any trick besides a brute-force calculation.