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.
[Math] Is Sum of digits related with Sum of Squares of its digit
elementary-number-theory
Best Answer
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.