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

Home > Numbers
Some prime sequences (Posted on 2018-07-04) Difficulty: 3 of 5
What numbers N are the sum of a sequence of consecutive primes such that the product of the first and last numbers in the sequence is N?

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Basic language version | Comment 2 of 11 |
2 * 5 = 10 =  2 + 3 + 5
3 * 13 = 39 =  3 + 5 + 7 + 11 + 13
5 * 31 = 155 =  5 + 7 + 11 + 13 + 17 + 19 + 23 + 29 + 31
7 * 53 = 371 =  7 + 11 + 13 + 17 + 19 + 23 + 29 + 31 + 37 + 41 + 43 + 47 + 53

The program has checked all primes up to the 201st prime, 1229. The highest prime actually used, 53, is the 16th prime.

DefDbl A-Z
Dim crlf$

Private Sub Form_Load()
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
  
 For stp = 1 To 200
   tot = prm(stp)
   For lstp = stp + 1 To 201
     tot = tot + prm(lstp)
     If tot = prm(stp) * prm(lstp) Then
        Text1.Text = Text1.Text & prm(stp) & " *" & Str(prm(lstp))
        Text1.Text = Text1.Text & " = " & prm(stp) * prm(lstp) & " = "
        For i = stp To lstp
          Text1.Text = Text1.Text & Str(prm(i))
          If i <> lstp Then Text1.Text = Text1.Text & " +"
        Next
        Text1.Text = Text1.Text & crlf
     End If
     DoEvents
   Next
 Next
  
  Text1.Text = Text1.Text & prm(201) & " done"
  
End Sub

Function prm(i)
  Dim p As Long
  Open "17-bit primes.bin" For Random As #111 Len = 4
  Get #111, i, p
  prm = p
  Close 111
End Function


  Posted by Charlie on 2018-07-04 12:48:06
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 (16)
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