mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Programming

Reply
 
Thread Tools
Old 2018-05-28, 13:57   #1
irina
 
Jul 2015

48 Posts
Arrow Mersenne prime number search algorithm

1. var k,l,n,s,j,d,c,y,r,x,i,h:biginteger;
begin
x:=31;
i:=32;
h:=1;
for var q:=1 to 100 do
begin
var a:=x div 2;
var b:=a-1;
repeat
b:=a;
a:=(a+x div a)div 2
until a>=b;
writeln;
s:=a;
n:=x-sqr(s);
k:=n div s; j:=n mod s; l:=s+k; d:= s-j;
repeat
s:=s-1;
d:=d-1;
r:=l-d;
c:=r div s;
y:=r mod s;
l:=l+1+c;
j:=y;
d:=s-j;
until j=0;
if (l=1) or (s=1) then writeln (x);
x:=x+i*63*h;
i:=i*32;
h:=h*2;
end;
end.

2.var k,l,n,s,j,d,c,y,r,x,i:biginteger;
q:integer;
begin
x:=127;
i:=64;
for q:=1 to 100 do
begin
var a:=x div 2;
var b:=a-1;
repeat
b:=a;
a:=(a+x div a)div 2
until a>=b;
writeln;
s:=a;
n:=x-sqr(s);
k:=n div s; j:=n mod s; l:=s+k; d:= s-j;
repeat
s:=s-1;
d:=d-1;
r:=l-d;
c:=r div s;
y:=r mod s;
l:=l+1+c;
j:=y;
d:=s-j;
until j=0;
if (l=1) or (s=1) then writeln (x);
x:=x+i*126;
i:=i*64;
end;
end.
irina is offline   Reply With Quote
Old 2018-05-29, 05:39   #2
ONeil
 
ONeil's Avatar
 
Dec 2017

2·5·11 Posts
Default

Quote:
Originally Posted by irina View Post
1. var k,l,n,s,j,d,c,y,r,x,i,h:biginteger;
begin
x:=31;
i:=32;
h:=1;
for var q:=1 to 100 do
begin
var a:=x div 2;
var b:=a-1;
repeat
b:=a;
a:=(a+x div a)div 2
until a>=b;
writeln;
s:=a;
n:=x-sqr(s);
k:=n div s; j:=n mod s; l:=s+k; d:= s-j;
repeat
s:=s-1;
d:=d-1;
r:=l-d;
c:=r div s;
y:=r mod s;
l:=l+1+c;
j:=y;
d:=s-j;
until j=0;
if (l=1) or (s=1) then writeln (x);
x:=x+i*63*h;
i:=i*32;
h:=h*2;
end;
end.

2.var k,l,n,s,j,d,c,y,r,x,i:biginteger;
q:integer;
begin
x:=127;
i:=64;
for q:=1 to 100 do
begin
var a:=x div 2;
var b:=a-1;
repeat
b:=a;
a:=(a+x div a)div 2
until a>=b;
writeln;
s:=a;
n:=x-sqr(s);
k:=n div s; j:=n mod s; l:=s+k; d:= s-j;
repeat
s:=s-1;
d:=d-1;
r:=l-d;
c:=r div s;
y:=r mod s;
l:=l+1+c;
j:=y;
d:=s-j;
until j=0;
if (l=1) or (s=1) then writeln (x);
x:=x+i*126;
i:=i*64;
end;
end.
Can you possibly program this in python?
ONeil is offline   Reply With Quote
Old 2018-05-30, 13:33   #3
BudgieJane
 
BudgieJane's Avatar
 
"Jane Sullivan"
Jan 2011
Beckenham, UK

2×32×13 Posts
Default

Quote:
Originally Posted by ONeil View Post
Can you possibly program this in python?
Surely that is left as an exercise for the reader?
BudgieJane is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
New PC dedicated to Mersenne Prime Search Taiy Hardware 12 2018-01-02 15:54
Low clock speeds on Mersenne Prime search Ammonia Hardware 2 2016-01-21 17:46
A Mersenne Prime Algorithm for Children Jonathan Data 3 2015-07-03 01:27
Number of distinct prime factors of a Double Mersenne number aketilander Operazione Doppi Mersennes 1 2012-11-09 21:16
Can I specify the range to search the Mersenne Prime? Unregistered Information & Answers 22 2012-03-20 11:38

All times are UTC. The time now is 02:38.

Tue Oct 20 02:38:13 UTC 2020 up 39 days, 23:49, 0 users, load averages: 2.18, 2.03, 1.89

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.