20031207, 11:06  #1 
Dec 2003
2^{4} 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 64bit integer Dim S As Int64 Dim I As Int64 P = CInt(txt1.Text) 'This converts txt1 Text into PInteger 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 Thanks in advance! 
20031207, 11:14  #2  
Nov 2002
2×37 Posts 
which value did you asign to M??
Quote:
Last fiddled with by andi314 on 20031207 at 11:15 

20031207, 11:20  #3 
Dec 2003
2^{4} Posts 
M=P
Code:
Dim P As Int64 'Int64 means 64bit integer Dim S As Int64 Dim I As Int64 P = CInt(txt1.Text) 'This converts txt1 Text into PInteger 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 
20031207, 11:24  #4 
Nov 2002
2·37 Posts 
maybe the size for your number are too small???

20031207, 11:32  #5 
Dec 2003
2^{4} 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? 
20031207, 11:36  #6 
Nov 2002
4A_{16} Posts 
maybe the modulo function doesnt work with such hich number??

20031207, 11:38  #7 
Dec 2003
2^{4} Posts 
maybe!?!

20031207, 11:39  #8 
Nov 2002
2·37 Posts 
which programming language do you use???

20031207, 11:42  #9 
Dec 2003
16_{10} Posts 
Microsoft Visual Basic.NET

20031207, 11:44  #10 
Nov 2002
2·37 Posts 
do you have any manual where you can look up, how far the mod function works???

20031207, 11:55  #11 
Dec 2003
2^{4} 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 
Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Modifying the Lucas Lehmer Primality Test into a fast test of nothing  Trilo  Miscellaneous Math  25  20180311 23:20 
LucasLehmer test  Mathsgirl  Information & Answers  23  20141210 16:25 
Question About LucasLehmer Test (JAVA)  jmanes92  Programming  9  20130222 22:19 
Question on Lucas Lehmer variant (probably a faster prime test)  MrRepunit  Math  9  20120510 03:50 
LucasLehmer Test  storm5510  Math  22  20090924 22:32 