i recently got interested in prime numbers and have used some python code to generate an algorithm that contiuously produces prime numbers sequentially. (given 2 and 3 to make the code simpler) There is a separate algorithm that i am working on that formulates the problem as a system of equations. Before i finish the next one i was wondering if there is any point to this???? The system is set up in such a manner that it calculates if n and n-1 have the same prime factors. If so then n must be a prime. It is currently set up to determine the overlap between two timesteps, and the column values multiplied by the header is the maximum number of multiples that can fit below the value n. This can also be assumed to a nonlinear function where every term is offset by a prime amount and has a prime coefficient, regularly outputs primes when the two equations are set to equal and it is true. Because p and p-1 cannot be equal then it is assumed that p is prime and it is added to the equation. I know there are problems around primes but i am unsure if this is at all contributional or if i am just posing a factoring problem differently?? I do not have a background in math so im sorry if i posed the question vaguely or was unable to elaborate on the formula well. Any input is appreciated.
import numpy as np listofprimes= np.array() number = np.array() i = 1 while i < 1000: pastmultiples = (number-1) // listofprimes multiples = number // listofprimes #print('checking : ',number) if np.array_equal(pastmultiples, multiples, equal_nan=False) : listofprimes = np.concatenate((listofprimes,number)) print('prime : ', number) number += 1 i += 1
Thats all of it. i can be set to any number 1000 is just for convenience. floor division for p and p-1 by smaller primes. If f(n) = f(n-1) then n must be prime. Add n to primes. Loop