mersenneforum.org  

Go Back   mersenneforum.org > Fun Stuff > Lounge

Reply
 
Thread Tools
Old 2016-01-01, 16:23   #12
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

838410 Posts
Default

Quote:
Originally Posted by xilman View Post
Countably infinite.
okay then what's the absolute fastest way you can code it.
science_man_88 is offline   Reply With Quote
Old 2016-01-02, 04:14   #13
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
República de California

2D7F16 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
okay then what's the absolute fastest way you can code it.
If by 'fast' you are referring to execution speed of the tests, several of us have been working on that for many years, and continue to do so. You are welcome to compare timings of your efforts to ours.

If OTOH by 'fast' you mean 'speed of coding it up', then you got us beat, hands-down. (But only if you neglect the coding time others put into the bignum package you are using.)
ewmayer is offline   Reply With Quote
Old 2016-01-02, 12:48   #14
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by ewmayer View Post
If by 'fast' you are referring to execution speed of the tests, several of us have been working on that for many years, and continue to do so. You are welcome to compare timings of your efforts to ours.

If OTOH by 'fast' you mean 'speed of coding it up', then you got us beat, hands-down. (But only if you neglect the coding time others put into the bignum package you are using.)
mine are all PARI/gp and suck even compared to the lucas example.

Last fiddled with by science_man_88 on 2016-01-02 at 12:55
science_man_88 is offline   Reply With Quote
Old 2016-01-02, 15:51   #15
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

I've thought about the fact that in the squaring version if s_n=a{M_n} then s_{n+1}=a^2{M_n}^2-2 which mod the next mersenne number is a^22^{n-1}-2 but that's not all that helpful when a's value is the larger part of that typically and in the s_n=2{s_{n-1}}^2-1 version(s) of the test you can find the relation that the next value is also 2{s_{n-1}-1}^2+4{s_{n-1}-1}+1 which is like the way mersenne numbers that have exponents in a cunningham chain of the first kind follow but I have a hard time finding a useful relationship to use to mod that one.

Last fiddled with by science_man_88 on 2016-01-02 at 15:53
science_man_88 is offline   Reply With Quote
Old 2018-08-22, 18:25   #16
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Here's another crappy version:
Code:
LL(p)=my(s=Mod(2,2^p-1));for(x=1,p-2,s=vecprod([2,s-1,s+1])+1);s
science_man_88 is offline   Reply With Quote
Old 2018-08-22, 21:25   #17
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
República de California

19·613 Posts
Default

Crappy-performing but functional bc code:
Code:
define lltest(p) {
	auto i,m,r; i = p-2; m = 2^p-1; r = 4;
	while(i--) {
		r = (r^2-2)%m;
	}
	return(r==0);
}
ewmayer is offline   Reply With Quote
Old 2018-08-22, 22:18   #18
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

EB216 Posts
Default

In Ruby....

Code:
def LL(p)
  s, n = 4, 2**p-1
  3.upto(p) { s=(s**2-2)%n }
  s==0
end

print "LL exponent : "
p = gets.to_i
puts LL(p)

Last fiddled with by paulunderwood on 2018-08-22 at 22:18
paulunderwood is offline   Reply With Quote
Old 2018-08-22, 22:34   #19
GP2
 
GP2's Avatar
 
Sep 2003

A1916 Posts
Default

Earlier in the thread someone mentioned the Rosetta Code page, with dozens of languages. None particularly efficient, though.

http://rosettacode.org/wiki/Lucas-Lehmer_test
GP2 is offline   Reply With Quote
Old 2018-08-22, 22:47   #20
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

2·32·11·19 Posts
Default

Quote:
Originally Posted by GP2 View Post
Earlier in the thread someone mentioned the Rosetta Code page, with dozens of languages. None particularly efficient, though.

http://rosettacode.org/wiki/Lucas-Lehmer_test
Ah! I did not handle exponent 2. Also (p-2).times maybe neater then 3.upto(p).

I guess the linked page is too small for George's source

Last fiddled with by paulunderwood on 2018-08-22 at 22:52
paulunderwood is offline   Reply With Quote
Old 2018-08-23, 23:06   #21
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
República de California

19·613 Posts
Default

Quote:
Originally Posted by paulunderwood View Post
Ah! I did not handle exponent 2.
No need - LL assumes p an odd prime.
ewmayer is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
The Joys of Cracked.com: 5 Ways We Ruined the Occupy Wall Street Generation Dubslow Soap Box 17 2012-05-14 08:51
RDS's unique pedagogic ways R.D. Silverman Soap Box 137 2012-01-07 07:52
ways to get rid of oil spills science_man_88 Puzzles 9 2010-07-30 21:22
Help needed to test Athlon64 code geoff Programming 7 2006-08-18 12:16
Creative ways to achieve Athlon 64 / Opteron optimization GP2 Hardware 11 2004-01-21 03:01

All times are UTC. The time now is 16:31.


Mon Aug 2 16:31:32 UTC 2021 up 10 days, 11 hrs, 0 users, load averages: 2.79, 2.57, 2.45

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.