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

Home > Numbers
The highest prime (Posted on 2014-05-16) Difficulty: 2 of 5
You are requested to partition the set of 10 digits (0,1,…,9) into a maximal number of subsets, such that in each set it is possible to create a prime number
using all its members.

What is the highest prime thus created?

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution my computer solution -- concatenation assumed Comment 8 of 8 |
At most six primes can be formed using each of the ten digits exactly once, as each prime must end with an odd digit or be 2. In addition to one of the primes having to be 2, another must be 5 as any number ending in 5 is not prime unless the number is 5 itself.

The program reports the 2 and the 5 as well as the other four primes that can be formed from such partitioning.

DefDbl A-Z
Dim pr(4), crlf$

Private Sub Form_Load()
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 a$ = "13467890": h$ = a$
 Do
   If Left(a$, 1) <> "0" Then
    If InStr("1379", Right(a$, 1)) > 0 Then
     a2$ = a$
     pct = 0
     good = 1
     Do While a2$ > ""
        For ix = 1 To Len(a2$)
          If InStr("1379", Mid(a2$, ix, 1)) > 0 Then
            pct = pct + 1
            pr(pct) = Val(Left(a2$, ix))
            If Left(a2$, 1) = "0" Then good = 0: Exit For
            a2$ = Mid(a2$, ix + 1)
            Exit For
          End If
        Next
        If good = 0 Then Exit Do
     Loop
     For i = 1 To 4
        If prmdiv(pr(i)) <> pr(i) Or pr(i) = 1 Then good = 0: Exit For
        If pr(i) < pr(i - 1) Then good = 0: Exit For
     Next
     
     If good Then
       flag = 0
       For i = 1 To 4
         If pr(i) > Max Then flag = 1: Max = pr(i)
       Next
       Text1.Text = Text1.Text & "2 5 "
       For i = 1 To 4
         Text1.Text = Text1.Text & Str(pr(i))
       Next
       If flag Then Text1.Text = Text1.Text & " ***"
       Text1.Text = Text1.Text + crlf$
       DoEvents
     End If
    End If
   End If
   permute a$
 Loop Until a$ = h$

End Sub


Function prmdiv(num)
 Dim n, dv, q
 If num = 1 Then prmdiv = 1: Exit Function
 n = Abs(num): If n > 0 Then limit = Sqr(n) Else limit = 0
 If limit <> Int(limit) Then limit = Int(limit + 1)
 dv = 2: GoSub DivideIt
 dv = 3: GoSub DivideIt
 dv = 5: GoSub DivideIt
 dv = 7
 Do Until dv > limit
   GoSub DivideIt: dv = dv + 4 '11
   GoSub DivideIt: dv = dv + 2 '13
   GoSub DivideIt: dv = dv + 4 '17
   GoSub DivideIt: dv = dv + 2 '19
   GoSub DivideIt: dv = dv + 4 '23
   GoSub DivideIt: dv = dv + 6 '29
   GoSub DivideIt: dv = dv + 2 '31
   GoSub DivideIt: dv = dv + 6 '37
 Loop
 If n > 1 Then prmdiv = n
 Exit Function

DivideIt:
 Do
  q = Int(n / dv)
  If q * dv = n And n > 0 Then
    prmdiv = dv: Exit Function
   Else
    Exit Do
  End If
 Loop

 Return
End Function

finds 13 ways of partitioning the 10 digits into six primes:

2 5  3 41 67 809 ***
2 5  3 41 89 607
2 5  3 47 61 809
2 5  3 47 89 601
2 5  3 67 89 401
2 5  3 7 41 6089 ***
2 5  3 7 41 8069 ***
2 5  3 7 41 8609 ***
2 5  3 7 461 809
2 5  3 7 641 809
2 5  7 43 61 809
2 5  7 43 89 601
2 5  7 61 83 409

So in one interpretation of the puzzle, any one of these lines can be used as the partitioning, and the rightmost number on the line is the largest prime created from that partitioning.

But to get a unique answer you can take a more restrictive interpretation of the last sentence: that the partitioning is to be done in such a way as to include the highest possible prime. To facilitate that, the *** in the above listing marks a partitioning that includes a prime higher than any prime in the list up to that point. The last such marked partitioning is

2 5  3 7 41 8609

and therefore 8609 is the highest prime that can be created thus.

  Posted by Charlie on 2014-05-16 12:49:52
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 (12)
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