As per my knowledge, I have seen the only following functions which will produce primes for $n$:
$n^2 - n + 41$
$n^2 + n + 41$
Of course both functions faile for $n = 41$ due to the polynomial representation. I tried to prepare a function which will generate primes continously. As we know that primes are infinite but there is a gaps between them and tough to produce all primes in a single function or algorithm. Please look my algorthm, which I belive that, it will produce only primes.
#include
int testForPrime (int n) { int p, i; p = 1; i = 3; int result = n; while (i < result) { result = n / i; if (n == i * result) { p = 0; i = n; } i = i + 2; } return (p); } int main (int argc, char * const argv[]) { int p, i, n; i = 3; n = 5; std::cout << "Initiating prime number generation sequence...\n\n1:2\n2: 3\n"; while (1) { p = testForPrime (n); if (p == 1) { std::cout << i << ": " << n << "\n"; i++; } n = n + 2; } return 0; }
For better undrestanding please see the my source file at by clicking EDIT of my post.
I would like to know the follwoing:
- Is my algorithm is true or may be need more modifications?
- If we restrict to number of primes less than x in terms of the zeros of the zeta function. The first term is $x/\log(x)$. The Riemann hypothesis is equivalent to the assertion that other terms are bounded by a constant times $\log(x)$ times the square root of $x$. The Riemann hypothesis asserts that all the 'non-obvious' zeros of the zeta function are complex numbers with real part $1/2$. how?
If you can give little more clarification on this second part, I will write another algorithm for justification of this second problem.