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

10010102 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 7410 Posts maybe the size for your number are too small???
 2003-12-07, 11:32 #5 BMgf     Dec 2003 24 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 10010102 Posts maybe the modulo function doesnt work with such hich number??
 2003-12-07, 11:38 #7 BMgf     Dec 2003 24 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 1610 Posts Microsoft Visual Basic.NET
 2003-12-07, 11:44 #10 andi314     Nov 2002 10010102 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 100002 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 18:50.

Sun Jul 25 18:50:19 UTC 2021 up 2 days, 13:19, 0 users, load averages: 2.33, 2.04, 1.81