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

Home > Numbers
Prime Product Permutation (Posted on 2005-03-21) Difficulty: 3 of 5
Find three different digits that no matter in what order they are arranged, the three digit number formed is the product of two primes.

See The Solution Submitted by Old Original Oskar!    
Rating: 3.2500 (4 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Exhaustive Search via computer program -- spoiler | Comment 1 of 6

  100   for D1=0 to 7
  200   for D2=D1+1 to 8
  300   for D3=D2+1 to 9
  400   Good=1
  500   B$=cutspc(str(D1))+cutspc(str(D2))+cutspc(str(D3))
  600   for Ii=1 to 6
  700    N=val(B$)
  800    P=2
  900    T=N:Ct=0
 1000    while P<=sqrt(T)
 1100      if T@P=0 then
 1200        :Ct=Ct+1:T=T//P
 1300      :else
 1400        :P=nxtprm(P)
 1500    wend
 1510   if T>1 then Ct=Ct+1
 1600    if N>99 and Ct<>2 then Good=0:cancel for:goto *NotGood
 1700    gosub *Permute(&B$)
 1800   next Ii
 1900   if Good then print D1,D2,D3
 2000   *NotGood
 2100   next D3
 2110   next D2
 2120   next D1
 2200   end
 2300 
 2400   *Permute(&A$)
 2500   local I,J,X$,Fl
 2600    X$=""
 2700    for I=len(A$) to 1 step -1
 2800     L$=X$
 2900     X$=mid(A$,I,1)
 3000     if X$<L$ then cancel for:goto *Outta
 3100    next I
 3200   *Outta
 3300    if I=0 then
 3400     :for J=1 to len(A$)\2
 3500     :X$=mid(A$,J,1)
 3600     :mid(A$,J,1)=mid(A$,len(A$)-J+1,1)
 3700     :mid(A$,len(A$)-J+1,1)=X$
 3800     :next J
 3900    :else
 4000     :for J=len(A$) to I+1 step -1
 4100     :if mid(A$,J,1)>X$ then cancel for:goto 4300:endif
 4200     :next J
 4300     :mid(A$,I,1)=mid(A$,J,1)
 4400     :mid(A$,J,1)=X$
 4500     :for J=1 to (len(A$)-I)\2
 4600     :X$=mid(A$,I+J,1)
 4700     :mid(A$,I+J,1)=mid(A$,len(A$)-J+1,1)
 4800     :mid(A$,len(A$)-J+1,1)=X$
 4900     :next J
 5000   return

finds 1, 7 and 8.

The zero was included among the digits even though it would lead to two permutations with a leading zero; even so, none were found with that allowance.

A modification to print the prime factors of the six permutations gives

 178:     2  89
 187:     11  17
 718:     2  359
 781:     11  71
 817:     19  43
 871:     13  67

  Posted by Charlie on 2005-03-21 15:15:26
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 (3)
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