Let $P$ be a two-digit prime number less than $100$ such that both digits are prime numbers. What is the sum of all such numbers, $P$?
Is there a quick way to solve this problem without listing all the numbers?
Let $P$ be a two-digit prime number less than $100$ such that both digits are prime numbers. What is the sum of all such numbers, $P$?
Is there a quick way to solve this problem without listing all the numbers?
Probably not -- the only valid digits are 2, 3, 5 and 7, so there are only 16 possibilities to check, which is surely faster than to try to be clever.
In fact, 2 and 5 clearly can't be the last digit, so there are only 8 actual values to try.
Simple in Mathematica:
Total@Select[Flatten@Outer[10 #1 + #2 &, mylist = Prime[#] & /@ Range[4], mylist], PrimeQ]
(* 186 *)