A formula for the first eleven primes: $ 2 \cdot (n + n / (27 / n)) + 1 / n - 1 $ So, just for kicks, and for an exercise, I've written an evolutionary algorithm to search for a prime number formula (I know, contain your laughter) that was limited to a set of operators and constants. My program came up with this:
$$ 2 \cdot (n + n / (27 / n)) + 1 / n - 1 $$
If $n$ is an integer such that $1 \leq n \leq 11$ and $/$ means the integer division such that $a / b = ⌊\frac{a}{b}⌋$, the above expression produces the first eleven prime numbers: 
$$2,3,5,7,11,13,17,19,23,29,31$$
However broad my question may be, I cannot help but ask: 

Is there a pattern in this expression that could be efficiently extended for it to generate more primes? This is probably the case, but is it completely useless, for nothing more than mere coincidence?

 A: Hum. Let $p_i$ be the $i$-th prime and consider
$$f(n)=\sum_{i=1}^ka_i\cdot \left\lfloor\frac{n}i\right\rfloor$$
for some $k$. We have
\begin{align}
f(1)&=a_1\\
f(2)&=2a_1+a_2\\
f(3)&=3a_1+a_2+a_3\\
\dots
\end{align}
It's easy to see that
$$\left\{
\begin{array}{c}
f(1)=p_1\\
f(2)=p_2\\
\vdots\\
f(k)=p_k
\end{array}
\right.$$
defines a system of linear equations on the $a_i$ which is uniquely solvable. In this manner, one can produce a formula that yields the first $k$ primes. This isn't quite similar to your formula, but it's something I guess.
A: 
Well, it is a nice curiosity, if you can use the evolutionary algorithm to generate a finite set of primes of your choice, then you can generate a function of two variables able to generate up to $63$ primes: the complete set of Euler primes. Do as follows:



*

*I am supposing that your algorithm is a kind of "perceptron"-like (so it makes some steps taking as input the result of the previous step). So define as the target the set of Euler lucky numbers, so your algorithm is intended to generate now the following primes: 


$$2, 3, 5, 11, 17, 41$$
So your function will generate a similar expression like the one of your question, for instance let us call it $f(x)$ such that $f:[1..6] \to [2,3,5,11,17,41]$


*

*Now, define $F(x,n)$ as the following function:


$$F(x,n)=n^2-n+f(x)$$


*

*$F(x,n)$ will generate the complete set of $63$ Euler primes for $x \in [1..6], n \in [1..f(x)-1]$, because each $f(1)..f(6)$ generates the degree $0$ coefficient of one of the existing Euler prime-generating polynomials.


If your algorithm is able to define the target of primes for a reduced set without getting very complex, then it will work. Indeed I did sometime ago something similar but using a Mills-like constant. 
