Are you familiar with the Fundamental Theorem of Arithmetic (so, by the FTA, this number would be unique, but maybe this is not sufficient for your application - read on)?
http://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmetic
Additionally, how many unique IDs do you need?
Have you considered how large of prime numbers you will need to represent that?
Maybe you want to use a product_id || serial_number || date & time-stamp or some mixing like that to guarantee a unique ID.
You can also consider using the new SHA-3 (Keccak) at: http://en.wikipedia.org/wiki/SHA-3 . You can take a large hash value and truncate it (but there is the possibility of collisions), so you can prepend the items above to avoid those.
Also, maybe something like this is what you are after: http://www.javapractices.com/topic/TopicAction.do?Id=56 .
RFC 4122: A Universally Unique IDentifier (UUID), covers this sort of thing and you might want to read it because this is likely what you are after (a secure way to generate a universally unique ID).
For security reasons, Unique identifiers which are "published" in some way may need special treatment, since the identifier may need to be difficult to guess or forge.
Just wanted to throw out some additional thoughts for your consideration given some of the comments and feedback above.
Regards -A
GIMPS just considers Mersenne primes, so there is a fixed formula.
However if you are looking for a "biggish" prime, say 1024-bits well suited for cryptography, that is a prime $p$ with $2^{1024} < p < 2^{1025}$. Out of the $2^{1024}$ numbers in the range, approximately
$$\frac{2^{1025}}{\log 2^{1025}} - \frac{2^{1024}}{\log 2^{1024}}$$
are prime. So the fraction which are prime is
$$\frac{2}{\log 2^{1025}} - \frac{1}{\log 2^{1024}}=
\frac{2}{1025\log 2} - \frac{1}{1024\log 2} = 0.001406$$
Since you can test as many as you want, that's not such bad odds.
Best Answer
Of any three consecutive integers, one is divisible by $3$. In particular, one of $2^n-1$, $2^n$, and $2^n+1$ is divisible by $3$. But $2^n$ is not divisible by $3$, so one of $2^n-1$ and $2^n+1$ is divisible by $3$.
If $n\gt 2$, then $2^n-1$ and $2^n+1$ are both bigger than $3$. One of them is divisible by $3$ and greater than $3$, so is not prime.