0
$\begingroup$

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?

$\endgroup$
2
  • $\begingroup$ Yes. Just list those numbers both of whose digits are prime. $\endgroup$
    – WillO
    Commented Jan 27, 2015 at 1:04
  • $\begingroup$ It is not such a big list as you perhaps imagine. Note that the unit digit is quite restricted. Your Question should be fully stated within the body, not relying on the title alone for its formulation. $\endgroup$
    – hardmath
    Commented Jan 27, 2015 at 1:25

2 Answers 2

4
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ You can eliminate two more pairs because the digits cannot be equal. $\endgroup$
    – N. S.
    Commented Jan 27, 2015 at 1:24
  • $\begingroup$ @N.S.: Yes, but then we're arguably reaching the point where it is quicker just to eliminate each of them individually than to formulate a general rule to cover them. $\endgroup$ Commented Jan 27, 2015 at 1:55
0
$\begingroup$

Simple in Mathematica:

Total@Select[Flatten@Outer[10 #1 + #2 &, mylist = Prime[#] & /@ Range[4], mylist], PrimeQ]

(* 186 *)

$\endgroup$
4
  • $\begingroup$ And why would this solution be voted down, when "answers" that merely state which digits need be considered are voted up, such as @HenningMakholm's? $\endgroup$ Commented Jan 27, 2015 at 16:57
  • $\begingroup$ I didn't DV, but my guess is: Because the question isn't "what are they" but rather "is there a better way to find them?" ... and, to the extent that i can understand what you did to find them (which you didn't explain), it is the same mechanism the OP wanted to improve upon. So you aren't answering the question asked, but the question that raised this question. $\endgroup$
    – Vynce
    Commented Jul 20, 2015 at 6:59
  • $\begingroup$ The "better way" is clearly to write a single, simple line of code. $\endgroup$ Commented Jul 20, 2015 at 15:46
  • $\begingroup$ ...which one doesn't understand? not a great way to go about getting math right, i think. Had you said "No, because that way is this easy" and also clarified what your code did, i suspect there would have been no downvote. But the combination of not actually answering the question asked, and not answering comprehensibly, make it pretty far from a "good" answer. PS arguing with reasons given for why a downvote is a good way to stop getting reasons given. $\endgroup$
    – Vynce
    Commented Jul 20, 2015 at 22:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .