mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Software

Reply
 
Thread Tools
Old 2017-07-13, 16:44   #12
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

I would track the index, incrementing by 1 each time. Then when you come to output, either output only the index, or else output the index followed by the full number.

I would also remove prime_file (in both places) since you don't seem to use it.
CRGreathouse is offline   Reply With Quote
Old 2017-07-13, 18:51   #13
rogue
 
rogue's Avatar
 
"Mark"
Apr 2003
Between here and the

635410 Posts
Default

Is it possible for an to go negative? If not, but it is in code, then you have problem.
rogue is offline   Reply With Quote
Old 2017-07-13, 19:01   #14
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

3,761 Posts
Default

this tests for negative "an":

Code:
SCRIPT

DIM anm1, 8
DIM anm2, 7
DIM anm3, 4
DIM anm4, 1
DIM anmin, 2^1
DIM anmax, 2^300000
DIM an
DIM abs_an
DIM index_n, 4

OPENFILEAPP prp_file,prp.txt

LABEL start
SET an,4*anm1-7*anm2+8*anm3-4*anm4

IF (an<0) THEN SET abs_an,-an ELSE SET abs_an,an

IF (abs_an<anmin) THEN GOTO next_iteration
IF (abs_an>anmax) THEN GOTO the_end

FACTORIZE index_n
IF (ISPRIME) THEN GOSUB test

LABEL next_iteration
SET anm4, anm3
SET anm3, anm2
SET anm2, anm1
SET anm1, an
SET index_n, index_n+1
GOTO start

LABEL test
PRP abs_an
IF (ISPRP) THEN WRITE prp_file,index_n
RETURN

LABEL the_end
CLOSEFILE prp_file
END
paulunderwood is offline   Reply With Quote
Old 2017-07-13, 19:54   #15
carpetpool
 
carpetpool's Avatar
 
"Sam"
Nov 2016

22×34 Posts
Post

Quote:
Originally Posted by paulunderwood View Post
this tests for negative "an":

Code:
SCRIPT

DIM anm1, 8
DIM anm2, 7
DIM anm3, 4
DIM anm4, 1
DIM anmin, 2^1
DIM anmax, 2^300000
DIM an
DIM abs_an
DIM index_n, 4

OPENFILEAPP prp_file,prp.txt

LABEL start
SET an,4*anm1-7*anm2+8*anm3-4*anm4

IF (an<0) THEN SET abs_an,-an ELSE SET abs_an,an

IF (abs_an<anmin) THEN GOTO next_iteration
IF (abs_an>anmax) THEN GOTO the_end

FACTORIZE index_n
IF (ISPRIME) THEN GOSUB test

LABEL next_iteration
SET anm4, anm3
SET anm3, anm2
SET anm2, anm1
SET anm1, an
SET index_n, index_n+1
GOTO start

LABEL test
PRP abs_an
IF (ISPRP) THEN WRITE prp_file,index_n
RETURN

LABEL the_end
CLOSEFILE prp_file
END
The code seems to work in general, that's good. I tried to set the odd values of the initial sequence negative, and for some reason only tested the even values. Either that, or I had the index off by 1.

Code:
SCRIPT

DIM anm1, 8
DIM anm2, -7
DIM anm3, 4
DIM anm4, 1
DIM anmin, 2^1
DIM anmax, 2^300000
DIM an
DIM abs_an
DIM index_n, 4

OPENFILEAPP prp_file,prp.txt

LABEL start
SET an,-4*anm1-7*anm2-8*anm3-4*anm4

IF (an<0) THEN SET abs_an,-an ELSE SET abs_an,an

IF (abs_an<anmin) THEN GOTO next_iteration
IF (abs_an>anmax) THEN GOTO the_end

FACTORIZE index_n
IF (ISPRIME) THEN GOSUB test

LABEL next_iteration
SET anm4, anm3
SET anm3, anm2
SET anm2, anm1
SET anm1, an
SET index_n, index_n+1
GOTO start

LABEL test
PRP abs_an
IF (ISPRP) THEN WRITE prp_file,index_n
RETURN

LABEL the_end
CLOSEFILE prp_file
END
carpetpool is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linear() -> Lucas in pfgw CRGreathouse Software 2 2017-06-14 16:05
Efficient testing in Pfgw Trejack Information & Answers 2 2016-04-30 05:30
Congruence storm5510 Math 27 2009-09-22 23:14
Primality-testing program with multiple types of moduli (PFGW-related) Unregistered Information & Answers 4 2006-10-04 22:38
congruence mod 2^p-1 abiessuunreg Miscellaneous Math 3 2005-03-07 21:03

All times are UTC. The time now is 18:28.


Sun Aug 1 18:28:33 UTC 2021 up 9 days, 12:57, 0 users, load averages: 2.44, 2.47, 2.59

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, 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.