mersenneforum.org Prime Often -
 Register FAQ Search Today's Posts Mark Forums Read

 2020-12-03, 22:34 #1 ONeil   Dec 2017 24·3·5 Posts Prime Often - Well after a certain amount of time of sitting on this formula I thought I would release the code to the world. Enter a prime number and the output at often times will be a different prime number, warning not always! Here is the largest prime number produced by the prime exponent 127 using the LARGER PRIMES CODE: 56713727820156410577229101238628035243 I uploaded two sets of codes one that makes the large primes and the other which makes smaller primes. LARGER PRIMES: Code: print('''Prime Often''') while True: r = int(input("Enter a Prime number to test if result is prime: ")) if r % 2 != 0: r = (2**r-1) y = ((((r//3)+1))) print('Prime Often >-->','|', y,'|') SMALLER PRIMES: Code: print('''Prime Often''') while True: r = int(input("Enter a Prime number to test if result is prime: ")) if r % 2 != 0: y = ((round((r/3)+1))) print('Prime Often >-->','|', y,'|') Last fiddled with by Uncwilly on 2020-12-03 at 23:38
 2020-12-03, 22:52 #2 Viliam Furik   "Viliam Furík" Jul 2018 Martin, Slovakia 7·53 Posts Just lookup "Wagstaff prime" on the Wikipedia...
 2020-12-03, 22:57 #3 mathwiz   Mar 2019 14410 Posts Prime early, prime often. In all seriousness, I have no idea what you're trying to accomplish with this.
2020-12-03, 23:05   #4
ONeil

Dec 2017

24·3·5 Posts

Quote:
 Originally Posted by mathwiz Prime early, prime often. In all seriousness, I have no idea what you're trying to accomplish with this.
I had no idea about wagstaff primes and also I just edited the smaller primes code using round so it produces more primes. mathwiz I'm trying to forecast primes without a prime generator or do it in a non-conventional manner.

I'm looking for a formula which can find huge primes and small primes. I wish I understood or knew the rule for which the prime gap is and if their is a universal formula.

I'm starting to think there is no universal formula for prime gaps or we would always find any prime number with out any worry.

2020-12-03, 23:14   #5
ONeil

Dec 2017

3608 Posts

Quote:
 Originally Posted by Viliam Furik Just lookup "Wagstaff prime" on the Wikipedia...
Hey Villiam Furik can you be sure my formula is exactly using the the Wagstaff formula?

I don't think you are correct.

2020-12-04, 05:58   #6
CRGreathouse

Aug 2006

175316 Posts

Quote:
 Originally Posted by ONeil SMALLER PRIMES: Code: print('''Prime Often''') while True: r = int(input("Enter a Prime number to test if result is prime: ")) if r % 2 != 0: y = ((round((r/3)+1))) print('Prime Often >-->','|', y,'|')
I tested this on the odd primes below 10^8 and found that it worked on 10.9% of them and failed on the balance. This is actually worse than you'd expect for a procedure that generates random odd numbers of their size.

2020-12-04, 10:22   #7
Viliam Furik

"Viliam Furík"
Jul 2018
Martin, Slovakia

7·53 Posts

Quote:
 Originally Posted by ONeil Hey Villiam Furik can you be sure my formula is exactly using the the Wagstaff formula? I don't think you are correct.
Yeah, I am sure you are using the Wagstaff formula.

1) Numbers (2^n - 1) are congruent to 1 (mod 3) when n is odd. When it is even, they are congruent to 0 (mod 3).

With that in mind, let's made a single edit to your formula:

2) y = r // 3 + 1

will become

3) y = (r // 3 + 1) * 3, which is equal to r // 3 * 3 + 3

4) That "// 3 * 3" part will guarantee that the number it spits out, not including the afterwards 3, will be divisible by 3, i.e. congruent to 0 (mod 3).

5) That number will be the nearest number from r divisible by 3, counting downwards. That will be, as we have shown in 1), r - 1, because r is 2^n - 1, which, for the odd n, is congruent 1 (mod 3), and r - 1 is 0 (mod 3), which is 2^n - 1 - 1 = 2^n - 2.

6) When we add the final 3, we get 2^n - 2 + 3 = 2^n + 1. If we take back the change in formula performed in 3), we will get the formula for y being (2^n + 1)/3, or (2 ** n + 1) // 3 in Python.

By simply evaluating the terms after performing a single change in formula, which we removed in the end, we got the said formula.

QED

 Similar Threads Thread Thread Starter Forum Replies Last Post dabaichi News 571 2020-10-26 11:02 ICWiener Software 38 2018-06-09 13:59 cuBerBruce Puzzles 3 2014-12-01 18:15 emily PrimeNet 3 2013-03-01 05:49 hhh Prime Cullen Prime 4 2007-09-21 16:34

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

Wed Feb 24 18:44:47 UTC 2021 up 83 days, 14:56, 0 users, load averages: 1.24, 1.75, 1.85