mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Miscellaneous Math

Reply
 
Thread Tools
Old 2021-05-09, 01:12   #1
AddieJ
 
May 2021

7 Posts
Default How to get to a prime from the previous prime number (sieve of Eratosthenes rediscovered)

I found a solution that will calculate each consecutive prime number from the previous prime number. I wrote about it in a humorous blog, but understand that it is actually true.

Read about it here: http://www.millieandtheboys.com/i-solved-prime/

How does one verify a math discovery??

Addie
AddieJ is offline   Reply With Quote
Old 2021-05-09, 01:34   #2
Batalov
 
Batalov's Avatar
 
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

23×32×7×19 Posts
Smile

Quote:
Originally Posted by AddieJ View Post
... but understand that it is actually true.
Now, that is humorous. You got us smiling, thanks!
Batalov is offline   Reply With Quote
Old 2021-05-09, 01:49   #3
AddieJ
 
May 2021

78 Posts
Default Am I crying Wolf?? Ha

Guys, I’m not bluffing. If you read the blog and look at the output files, those are actually calculated using an algorithm. I have all the data to back it up.
AddieJ is offline   Reply With Quote
Old 2021-05-09, 10:46   #4
ZFR
 
ZFR's Avatar
 
Feb 2008
Bray, Ireland

2·79 Posts
Default

Quote:
Originally Posted by AddieJ View Post

How does one verify a math discovery??
For starters, one needs something to verify.

Post your method/code.
ZFR is offline   Reply With Quote
Old 2021-05-09, 12:03   #5
AddieJ
 
May 2021

7 Posts
Default

That's fair. I'll get right to it then!

I've attached the following files:

Millie_Code_Prime_Solver_VB_Notepad.txt - this is the code from VB copy and pasted so that you can see it.

Prime.exe - Try it! If you leave the n and m as the default, it will calculate the first 100 prime numbers and place them into an output text file. You must change the output file location to match where the .exe file is and choose a file name.
Mod note: The .exe has been put in a zip with the password of: password
This is to protect people from accidentally running code from an unknown source on their machine.


output.txt - This is the output when the defaults are left as n = 100 and m = 10000. The first column is counting primes and the 2nd column is the prime number. The second prime number is '3' and the 99th prime number is '523' and everything in between.

I posted a few photos so that you can see I had to boot up my old computer (because that's where I have VB) to grab the VB code and paste it into Notepad. The files on my computer were saved on April 8, 2018, which is the weekend I did this... just to show you that there is truth to this. (The 2003 file was actually saved today, but my old computer doesn't work unless I enter an old date...)

I should add, that I visualize all this in Excel. It's incredible and also reveals why there will always be twin primes!

Verify away :)
Attached Thumbnails
Click image for larger version

Name:	2018_Prime_Solution_files.jpg
Views:	67
Size:	333.9 KB
ID:	24847   Click image for larger version

Name:	Prime_on_old_computer_reduced.jpg
Views:	67
Size:	175.0 KB
ID:	24848  
Attached Files
File Type: txt Millie_Code_Prime_Solver_VB_Notepad.txt (4.4 KB, 67 views)
File Type: txt output.txt (1.7 KB, 60 views)
File Type: zip Prime.zip (4.9 KB, 47 views)

Last fiddled with by Uncwilly on 2021-05-09 at 20:18 Reason: Change .exe to a zip
AddieJ is offline   Reply With Quote
Old 2021-05-09, 12:27   #6
AddieJ
 
May 2021

7 Posts
Default

You can change the input values to calculate more or less prime numbers (n). Just note that input m needs to get exponentially greater as you choose to calculate more primes. It’s basically a guess at how many “rows” are required and many of them are filled with zeros. If your m isn’t large enough it won’t complete the calculation properly. I’m sure there is a way to streamline this, but my coding skills are very limited.
AddieJ is offline   Reply With Quote
Old 2021-05-09, 17:24   #7
slandrum
 
Jan 2021
California

E416 Posts
Default

At a quick glance at the code this appears to be a basic implementation of the sieve of Eratosthenes. This is a well known method, and works well to generate very small primes.

This is not going to find record sized primes, you won't even find 20 digit primes with this, you will be out of memory and time very quickly.
slandrum is offline   Reply With Quote
Old 2021-05-09, 19:21   #8
Dr Sardonicus
 
Dr Sardonicus's Avatar
 
Feb 2017
Nowhere

116308 Posts
Default

Looks like a sieve to me. Sieving is useful to eliminate composites with small prime factors from a candidate list, but as a standalone prime-proving method you would have to sieve out by all the primes up to the square root of your candidate, which be prohibitively slow for numbers of any size.

Also, I also noticed that a lot of the loops had file reads and writes. I'm no computer expert, but I think even with fairly small numbers, that would tend to slow things down a great deal.

Some packages have functions that give the next (probable) prime, such as Pari-GP's nextprime() function. If my understanding is correct, it excludes multiples of 2, 3, 5, and 7 as candidates (for arguments larger than 6, anyway), and applies its BPSW pseudoprime test until it finds a number that "passes" the test. The output is not guaranteed to be prime, but if it is not very large (say a couple hundred decimal digits) Pari's isprime() prime-proving function could then be used to be certain.

"Everybody knows" there are infinitely many composite numbers that are BPSW probable primes, but nobody knows how to prove it, and AFAIK not a single example has been produced.
Dr Sardonicus is online now   Reply With Quote
Old 2021-05-11, 00:19   #9
AddieJ
 
May 2021

7 Posts
Wink

Quote:
Originally Posted by slandrum View Post
At a quick glance at the code this appears to be a basic implementation of the sieve of Eratosthenes. This is a well known method, and works well to generate very small primes.

This is not going to find record sized primes, you won't even find 20 digit primes with this, you will be out of memory and time very quickly.
So you’re saying Eratosthenes beat me to it, huh? Shucks. You're definitely right… it’s a tedious method and takes a lot of memory. No prize primes here.
AddieJ is offline   Reply With Quote
Old 2021-05-11, 00:24   #10
AddieJ
 
May 2021

7 Posts
Default

I posted my Excel worksheet and reposted my VB code file with explanations of how it was programmed. If anyone is interested, you can see a little more into my thinking and how each column of values produces the next prime number.

I don’t know if this is just a backwards way of coming up with a sieving method. It is how I started in the process and then I looked for patterns that could be repeated. I have a note that the rows for the code developed for each column is the previous prime squared (gets large quickly, but there are a lot of wasted zero values). The code itself (by code, I mean the column of values below the blue box number) has a midpoint and mirrors itself back to the start. It grows from the midway point and why I speculate that there will always be twin primes since those “twos” will eventually add to the next prime number.

Btw, a lot of those read and writes within loops was me troubleshooting the process and the final version placed a “ ‘ “ in front so that the program ignores the command. The only write command occurs at each prime number. It is, however, a tedious method of looking at every row to check if the value is ‘zero’ or not.

Anyway, that's all I've got! I will likely take a quiet leave from math forums, but it was fun. :) Good luck finding the BIG ones.
Attached Files
File Type: zip prime_code.zip (1,009.3 KB, 47 views)
AddieJ is offline   Reply With Quote
Old 2021-05-11, 00:45   #11
Xyzzy
 
Xyzzy's Avatar
 
Aug 2002

207B16 Posts
Default

Quote:
Originally Posted by AddieJ View Post
I will likely take a quiet leave from math forums, but it was fun. :)
Or you could stick around and have fun learning with us!

Xyzzy is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visualising the Sieve of Eratosthenes a nicol Miscellaneous Math 0 2020-10-20 14:05
Sieve of Eratosthenes bhelmes Number Theory Discussion Group 43 2018-03-13 01:04
New GPU accelerated sieve of Eratosthenes cseizert Programming 8 2016-10-27 05:55
Sieve of Eratosthenes Raman Programming 4 2009-01-19 17:12
Sieve of Eratosthenes jchein1 Homework Help 6 2007-08-27 13:51

All times are UTC. The time now is 22:07.


Thu Oct 28 22:07:30 UTC 2021 up 97 days, 16:36, 0 users, load averages: 2.67, 1.53, 1.36

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.