Can this generate all primes but not any composite numbers?

84 Views Asked by At

$\sqrt{24n+1}$ can generate all primes from 1 to 100 (except for primes from 2 to 12), without any composite numbers in between as long as it follows a few rules. (assuming $\sqrt{24n+1}$ is an integer.)

  1. If $n-1$ is a multiple of 5, $\sqrt{24n+1}$ will not return a prime.
  2. If $n\div7$ gives a remainder of 2, $\sqrt{24n+1}$ will return a multiple of 7 including 7 itself.
  3. If $n\div11$ gives a remainder of 5, $\sqrt{24n+1}$ will return a multiple of 11 including 11 itself.

So my question is, if I follow these rules, can I get all the primes?

I have a python script that tests this prime generator:

import math
n = 1
while True:
    num = math.sqrt(24*n+1)
    if float(int(num)) == float(num):
        if (n-1)%5==0:
            pass
        elif n%7==2:
            pass
        elif n%11==5:
            pass
        else:
            print('24 times '+str(n)+' minus 1 is a prime. The result is: '+str(num))
    if n>=400:
        break
    n+=1

If I delete the n>=400 part can I generate all primes?

1

There are 1 best solutions below

0
On

All the primes bigger than $11$ will show in the sequence but also a lot of composite numbers too. For example $169$.

So no, this is not a prime generator.

Your python program will write that $169$ is prime and this is false.