Find my number

My number:

  1. Is a 3-digit number.
  2. All its digits are prime digits.
  3. A number formed by its 1st 2 digits is prime.
  4. So is the number formed by its last 2 digits.
  5. It is the smallest number satisfying the above conditions.

Find it.

Rem: The digits in my number do not have to be distinct


The answer is 237.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Danish Ahmed
Jan 15, 2015

a) Prime digits are 2,3,5,7

b) 2 is the smallest of these.

c) 23 is the smallest two digit prime using these digits that starts with 2. So, problem is solved if I can just form a two digit prime starting with 3 and one of those digits.

d) Oh yes, I can, it is 37. (32, 33 and 35 are not prime)

So final answer is 237.

Brock Brown
Jan 15, 2015
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from math import sqrt
def is_prime(x):
    if x < 2:
        return False
    i = 2
    while i <= sqrt(x):
        if x % i == 0:
            return False
        i+=1
    return True
for n in xrange(100,1000):
    solved = True
    s = str(n)
    for digit in s:
        if not is_prime(int(digit)):
            solved = False
            break
    if not is_prime(int(s[:2])):
        solved = False
    if not is_prime(int(s[1:3])):
        solved = False
    if solved:
        print "Answer:", n
        break

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...