mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Programming

Reply
 
Thread Tools
Old 2003-12-07, 11:06   #1
BMgf
 
BMgf's Avatar
 
Dec 2003

24 Posts
Angry 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!
BMgf is offline   Reply With Quote
Old 2003-12-07, 11:14   #2
andi314
 
andi314's Avatar
 
Nov 2002

2×37 Posts
Default

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
andi314 is offline   Reply With Quote
Old 2003-12-07, 11:20   #3
BMgf
 
BMgf's Avatar
 
Dec 2003

24 Posts
Default

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!
BMgf is offline   Reply With Quote
Old 2003-12-07, 11:24   #4
andi314
 
andi314's Avatar
 
Nov 2002

2·37 Posts
Default

maybe the size for your number are too small???
andi314 is offline   Reply With Quote
Old 2003-12-07, 11:32   #5
BMgf
 
BMgf's Avatar
 
Dec 2003

1016 Posts
Default

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?
BMgf is offline   Reply With Quote
Old 2003-12-07, 11:36   #6
andi314
 
andi314's Avatar
 
Nov 2002

2×37 Posts
Default

maybe the modulo function doesnt work with such hich number??
andi314 is offline   Reply With Quote
Old 2003-12-07, 11:38   #7
BMgf
 
BMgf's Avatar
 
Dec 2003

1610 Posts
Default

maybe!?!
BMgf is offline   Reply With Quote
Old 2003-12-07, 11:39   #8
andi314
 
andi314's Avatar
 
Nov 2002

2×37 Posts
Default

which programming language do you use???
andi314 is offline   Reply With Quote
Old 2003-12-07, 11:42   #9
BMgf
 
BMgf's Avatar
 
Dec 2003

24 Posts
Default

Microsoft Visual Basic.NET
BMgf is offline   Reply With Quote
Old 2003-12-07, 11:44   #10
andi314
 
andi314's Avatar
 
Nov 2002

2×37 Posts
Default

do you have any manual where you can look up, how far the mod function works???
andi314 is offline   Reply With Quote
Old 2003-12-07, 11:55   #11
BMgf
 
BMgf's Avatar
 
Dec 2003

1610 Posts
Default

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
BMgf is offline   Reply With Quote
Reply

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 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

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

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.