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

Home > Numbers
Minimal Primes (Posted on 2012-04-24) Difficulty: 3 of 5
409 is an interesting prime number. If you remove any number of its digits, then you will get a number that is not prime.

4=2^2
0=not prime
9=3^2
40=2^3*5
49=7^2
09=9=3^2

Call a number with this property a minimal prime. Find all minimal primes.

No Solution Yet Submitted by Math Man    
Rating: 4.6667 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
of course it also inspires a computer program | Comment 3 of 5 |

This tests whether an input number is a minimal prime, and includes the single-digit primes:

   10     repeat
   20       input Tst:Tst=cutspc(str(Tst))
   30       Pr=""
   40       Good=1
   50       if prmdiv(val(tst))<val(tst) then good=0:else gosub *Testing(1)
   60       if Good then print "good":else print "bad"
   65     until tst="0"
   70     end
   80     
   90       *Testing(Psn)
  100       if Psn=len(Tst) then
  110         :Prtst=val(Pr)
  120         :if prmdiv(Prtst)=Prtst and Prtst<>0 and Prtst<>1 then Good=0:endif
  130       :else
  140         :gosub *Testing(Psn+1)
  150       Pr=Pr+mid(Tst,Psn,1)
  160       if Psn=len(Tst) and Psn>len(Pr) then
  170         :Prtst=val(Pr)
  180         :if prmdiv(Prtst)=Prtst and Prtst<>0 and Prtst<>1 then Good=0:endif
  190       if Psn<len(Tst) then
  200         :gosub *Testing(Psn+1)
  205       pr=left(pr,len(pr)-1)
  210       return

 


  Posted by Charlie on 2012-04-24 16:50:53
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 (4)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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