All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Inverted Primes (Posted on 2006-12-15) Difficulty: 4 of 5
In the window of my pocket calculator, I can see a six-figure number, abcdef, with distinct digits between 1 and 9. A close inspection of the digits reveals that abcdef, cdef, and def are all prime numbers.

If I turn the calculator upside-down, I see that uvwxyz and wxyz are also prime numbers.

Which number is displayed in the window of my pocket calculator and what is the upside-down version of it?

Full credit for this problem goes to Ajit Athle who has very kindly given his permission for the puzzle to be posted here.

See The Solution Submitted by Josie Faulkner    
Rating: 3.7778 (9 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution without Internet search or Excel | Comment 3 of 7 |
(In reply to Solution (spoiler) by Leming)

   10   N=99999
   20   while N<999999
   30     N=nxtprm(N)
   40     Ns=cutspc(str(N))
   50     Good=1:Bkwd=""
   55     for I=1 to len(Ns)-1
   56       if instr(mid(Ns,I+1,*),mid(Ns,I))>0 then Good=0
   57     next
   60     for I=1 to len(Ns)
   70       if instr("0347",mid(Ns,I,1))>0 then Good=0
   71       C=mid(Ns,I,1):if C="6" then C="9":else if C="9" then C="6"
   75       Bkwd=C+Bkwd
   80     next
   90     P1=val(mid(Ns,3,*)):P2=val(mid(Ns,4,*))
   91     P3=val(Bkwd):if prmdiv(P3)<>P3 then Good=0
   94      P4=val(mid(Bkwd,3,*)):if prmdiv(P4)<>P4 then Good=0
  100     if Good=1 and prmdiv(P1)=P1 and prmdiv(P2)=P2 then print N;P1;P2;prmdiv(P3);prmdiv(P4):Ct=Ct+1
  200   wend

finding

158269  8269  269  692851  2851

I could have used nested ifs and premature exits from loops, but UBASIC's structure makes that not worth the bother just to get an answer in a fraction of a second rather than 2 seconds.


  Posted by Charlie on 2006-12-15 11:15:45
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (15)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information