![]() |
![]() |
#1 |
Dec 2003
24 Posts |
![]()
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 Thanks in advance! |
![]() |
![]() |
![]() |
#2 | |
Nov 2002
7410 Posts |
![]()
which value did you asign to M??
Quote:
Last fiddled with by andi314 on 2003-12-07 at 11:15 |
|
![]() |
![]() |
![]() |
#3 |
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 |
![]() |
![]() |
![]() |
#4 |
Nov 2002
2×37 Posts |
![]()
maybe the size for your number are too small???
|
![]() |
![]() |
![]() |
#5 |
Dec 2003
208 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? |
![]() |
![]() |
![]() |
#6 |
Nov 2002
2×37 Posts |
![]()
maybe the modulo function doesnt work with such hich number??
|
![]() |
![]() |
![]() |
#7 |
Dec 2003
24 Posts |
![]()
maybe!?!
![]() |
![]() |
![]() |
![]() |
#8 |
Nov 2002
2×37 Posts |
![]()
which programming language do you use???
|
![]() |
![]() |
![]() |
#9 |
Dec 2003
100002 Posts |
![]()
Microsoft Visual Basic.NET
|
![]() |
![]() |
![]() |
#10 |
Nov 2002
2×37 Posts |
![]()
do you have any manual where you can look up, how far the mod function works???
|
![]() |
![]() |
![]() |
#11 |
Dec 2003
24 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 | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Modifying the Lucas Lehmer Primality Test into a fast test of nothing | Trilo | Miscellaneous Math | 25 | 2018-03-11 23:20 |
Lucas-Lehmer test | Mathsgirl | Information & Answers | 23 | 2014-12-10 16:25 |
Question About Lucas-Lehmer Test (JAVA) | jmanes92 | Programming | 9 | 2013-02-22 22:19 |
Question on Lucas Lehmer variant (probably a faster prime test) | MrRepunit | Math | 9 | 2012-05-10 03:50 |
Lucas-Lehmer Test | storm5510 | Math | 22 | 2009-09-24 22:32 |