Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sophie Germain Primes
#7
(Oct-28-2017, 03:08 AM)heiner55 Wrote: If I google for "prime number algorithm", I get a lot of suggestions.
Maybe you should also google.

It is enough to end the for-loop  if sqrt(n) instead of n/2.

You could save the result of isPrime(2*i+1), because you need it later again for isPrime(i).

That's actually quite a bit faster. Thank you.
Reply


Messages In This Thread
Sophie Germain Primes - by PythonLamer - Oct-27-2017, 06:26 PM
RE: Sophie Germain Primes - by heiner55 - Oct-27-2017, 06:58 PM
RE: Sophie Germain Primes - by PythonLamer - Oct-27-2017, 07:08 PM
RE: Sophie Germain Primes - by heiner55 - Oct-27-2017, 07:20 PM
RE: Sophie Germain Primes - by PythonLamer - Oct-27-2017, 09:01 PM
RE: Sophie Germain Primes - by heiner55 - Oct-28-2017, 03:08 AM
RE: Sophie Germain Primes - by PythonLamer - Oct-28-2017, 04:44 AM
RE: Sophie Germain Primes - by heiner55 - Oct-28-2017, 05:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help to identify Mersenne Primes, I do need a search pattern. Pleiades 0 1,957 Dec-03-2019, 11:05 PM
Last Post: Pleiades
  Convert Vba Primes to Python Primes jackhj 1 2,448 Apr-18-2018, 12:19 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020