Loading Now

primeDigits

You are given a positive integer N, your task is to calculate the total number of primes less than or equal to N with additional requirement that each digit of those primes should be a prime number itself.

Example

  • For N = 11, the output should be primeDigits(11) = 4.
    There are 5 primes less than N or equal to it: 2, 3, 5, 7 and 11. But there is a digit 1 (even two of them) in 11, and 1 is not a prime number. Thus, the answer is 4.

Input/Output

  • [execution time limit] 0.5 seconds

  • [input] integer N

    Constraints:

    0 ≤ N ≤ 106

  • [output] integer

Post Comment

Contact