This can be tested efficiently due to a theorem of Shallit, which builds on a classical result on combinatorics on words:
Every prime has one of 2, 3, 5, 7, 11, 19, 41, 61, 89, 409, 449, 499, 881, 991, 6469, 6949, 9001, 9049, 9649, 9949, 60649, 666649, 946669, 60000049, 66000049, and 66600049 (Sloane's A071062) as a subsequence of its decimal digits.
To implement efficiently, I would suggest making an array of permissible 3-digit sequences and reducing mod 1000 (perhaps repeatedly, if testing shows it to be efficient). If you get a hit, you can short-circuit and return "true". Otherwise, convert the number to a string and use a standard regular expression library to efficiently test if
[2357]|1.*[19]|(?:8.*8|9.*(?:0.*0|9)|[46]).*1|(?:4.*[049]|(?:6.*4|9.*4(?:.*6){2}).*6|(?:9.*[069]|6.*(?:(?:0.*0|6.*[06])(?:.*0){3}|(?:6.*6|0).*6|9)).*4|8).*9
matches your number. This should take time linear in the length of the input number, both for conversion (if using an efficient algorithm) and regex testing (if using an efficient algorithm with regex preprocessing).
If you check the whole number in 1000-digit increments you can leave off the testing of the one-digit numbers.
First of all, statement $2$ is false :
Since the sum of the digits of $N$ is $43\equiv 7\pmod9$, we know that $N\equiv 7\pmod9$. However, since there is no $m\in\mathbb N$ such that $m^3\equiv 7\pmod9$, we know that statement $2$ is false.
As a result, we have to find $N$ which satisfies both statement $1$ and $3$. Here, note that
$$m^2\equiv 7\pmod9\iff m\equiv 4,5\pmod9.$$
This fact will enable you to eliminate many cases.
So, we have $66$ cases to check if the sum of the digits of $m^2$ is $43$ :
$$m=418+9t, 419+9t\ \ (t=0,1,\cdots,32).$$
Best Answer
Find (1) The number of integers in the range, and (2) the number of integers in the range having only odd digits. Then subtract.