Can this function be a new test for primality? The following function returns always 0 only if a number is not prime.
$$
H(x)=\prod_{i=2}^{x-1}\left\{\left[\sum_{k=1}^{x/i}(-i)\right]+x\right\}
$$
what do you think?
Bye!
 A: Your formula is essentially a computer program which iterates all integers in the range $[2,x−1]$.
One can easily establish such formula, for example:
$$F_n=\left\lfloor\frac{\left(\sum\limits_{k=2}^{n-1}\left\lceil\frac{{n}\bmod{k}}{n}\right\rceil\right)+2\cdot\left\lceil\frac{n-1}{n}\right\rceil}{n}\right\rfloor$$
The real challenge is to establish a formula which is not "computationally worthless".
A: Let us take the formula apart slowly.
First we have a product over all the possible divisors of $x$. The product will be zero if just one factor is zero, so claiming that $H(x)$ is 0 only if $x$ is not prime, amounts to claiming that if $x$ is composite, one of the factors will be zero - my guess is that we'll get a zero if $i$ is a factor of $x$.
Then let us look at the sum
$$
\sum_{k=1}^{x/i}(-i)
$$
$i$ is a constant in the sum, so this is
$$
-i\left\lfloor\frac{x}{i}\right\rfloor
$$
if $i$ is a divisor of $x$ is this is $-x$, else it will be smaller. So if $i$ is a divisor of $x$ we get zero when adding $x$, if it isn't we get some positive number. So I guessed right.

Following up on the comments, there are plenty of ways to write formulas without "computer programming statements" that give a result that shows if a number is prime, but when it comes to primality testing formulas aren't worth much, it's the computational complexity it depends on, and your formula is not good in that regard, it involves a lot of calculations that are not be needed.
