mersenneforum.org Lucas Lehmer test question?
 Register FAQ Search Today's Posts Mark Forums Read

 2003-12-07, 11:06 #1 BMgf     Dec 2003 24 Posts Lucas Lehmer test question? I don't know way, but this test doesn't working when I input 31 in txt1.(it works with smaller prime numbers) Code:  Dim P As Int64 'Int64 means 64-bit integer Dim S As Int64 Dim I As Int64 P = CInt(txt1.Text) 'This converts txt1 Text into P-Integer S = 4 For I = 3 To M S = ((S ^ 2) - 2) Mod ((2 ^ P) - 1) Next If S = 0 Then MsgBox("It's a prime") Else MsgBox("It's not a prime") End If Any help? Thanks in advance!
2003-12-07, 11:14   #2
andi314

Nov 2002

2×37 Posts

which value did you asign to M??

Quote:
 For I = 3 To M
so the loop will never end

Last fiddled with by andi314 on 2003-12-07 at 11:15

 2003-12-07, 11:20 #3 BMgf     Dec 2003 24 Posts M=P Code:  Dim P As Int64 'Int64 means 64-bit integer Dim S As Int64 Dim I As Int64 P = CInt(txt1.Text) 'This converts txt1 Text into P-Integer S = 4 For I = 3 To P S = ((S ^ 2) - 2) Mod ((2 ^ P) - 1) Next If S = 0 Then MsgBox("It's a prime") Else MsgBox("It's not a prime") End If I made mistake in retyping!
 2003-12-07, 11:24 #4 andi314     Nov 2002 2·37 Posts maybe the size for your number are too small???
 2003-12-07, 11:32 #5 BMgf     Dec 2003 1016 Posts Int64 can hold numbers up to 2^63 so, it shouldn't be the problem. Also, I don't get any error message like I get with i.e. P = 63 (overflow). Any other idea?
 2003-12-07, 11:36 #6 andi314     Nov 2002 2×37 Posts maybe the modulo function doesnt work with such hich number??
 2003-12-07, 11:38 #7 BMgf     Dec 2003 1610 Posts maybe!?!
 2003-12-07, 11:39 #8 andi314     Nov 2002 2×37 Posts which programming language do you use???
 2003-12-07, 11:42 #9 BMgf     Dec 2003 24 Posts Microsoft Visual Basic.NET
 2003-12-07, 11:44 #10 andi314     Nov 2002 2×37 Posts do you have any manual where you can look up, how far the mod function works???
 2003-12-07, 11:55 #11 BMgf     Dec 2003 1610 Posts It's not problem in that! Code:  Dim P As Int64 Dim S As Int64 Dim M As Int64 Dim I As Int64 P = CInt(txt1.Text) S = 4 M = (2 ^ P) - 1 For I = 3 To P S = (S ^ 2) - 2 While S >= M S = S - ((S \ M) * M) ' \ - it divides S with M i.e. 5\2 = 2 End While Next If S = 0 Then MsgBox("It's a prime") Else MsgBox("It's not a prime") End If I replaced mod function with this and it's still the same

 Similar Threads Thread Thread Starter Forum Replies Last Post Trilo Miscellaneous Math 25 2018-03-11 23:20 Mathsgirl Information & Answers 23 2014-12-10 16:25 jmanes92 Programming 9 2013-02-22 22:19 MrRepunit Math 9 2012-05-10 03:50 storm5510 Math 22 2009-09-24 22:32

All times are UTC. The time now is 19:03.

Thu May 28 19:03:34 UTC 2020 up 64 days, 16:36, 0 users, load averages: 1.37, 1.67, 1.59