What exactly do you mean "yields only prime numbers"?
If you mean a formula that when given the numbers n=1, 2, 3, ... and so on generates the nth Prime number (or a different prime number for each n) then no.
If you mean an algorithm whereby a number can be tested to be a prime number then yes.
(Using this prime_test algorithm, a simple algorithm can be written that would supply numbers one at a time to it and use its result to decide whether to yield the tested number or not, only yielding those numbers which pass the test.)
Chat with our AI personalities