I was wondering, can a prime number be negative? We had a question over at security.se which stated that prime generation with openssl:

openssl dhparam -text 1024

results in a 1024-bit number to which leading zeros are added (resulting in 1032 bits). It could be the case that this is done to sign the integer, however it was my believe that negative primes did not exist?

  • 9
    $\begingroup$ Depends on the definition, but mathematicians consider $-7$ a prime, usually. In algebra, they are considered the "same prime" in some obvious sense. Usually, you don't need to deal with the negative primes, but in other algebras there's no obvious way to pick the "right" primes. $\endgroup$ – Thomas Andrews Aug 5 '13 at 4:27
  • $\begingroup$ en.wikipedia.org/wiki/Prime_number $\endgroup$ – Amzoti Aug 5 '13 at 4:28
  • 1
    $\begingroup$ on a sidenote, all these openssl computations should be performed with unsigned big integers and the padding to $1032$ bits is only needed to prevent an accidental interpretation of negative numbers in case some programmer forgot that restriction. :) $\endgroup$ – Hagen von Eitzen Aug 5 '13 at 5:54
  • $\begingroup$ Since nobody bring that up yet, may I bring up Gaussian integers? In any case, it should not have any effect (at least not on RSA), other than the fact that you need to be careful when computing $\varphi$ and some implementation-dependent issue on dividing by negative number $\endgroup$ – Gina Jan 5 '14 at 19:26
  • $\begingroup$ @ThomasAndrews is there anything you can cite pertainging to "mathematicians consider −7 a prime". I have just never heard of negatives being considered prime. Every defenition I have ever seen only considers Natrual numbers > 1. $\endgroup$ – KBusc Sep 8 '14 at 16:54

A prime number like $7$ represents all of the values that both divide 7 and are multiples of it. Then 7 simply os the representive form of it. So, of the integers, 7 represents both 7 and -7.

Sometimes you might want all primes to be 1 modulo 4 or 6, in which case, you might get -7 as the name form.

In other systems, like the gaussian integers, a prime likr $2+i$, can represent that and its multiples by powers of $i$. Other systems, like $x+y\sqrt{2}$, a prime like $1+2\sqrt{2}$, is one of an infinite number of values that divide this, and are divisable by this prime.

For the integers, it is usually representive to make the name prime greater than zero.

  • $\begingroup$ Are you referring to prime ideals? $\endgroup$ – Zach L. Aug 5 '13 at 5:58
  • $\begingroup$ I don't know that term. You can take in an integer set, that $x \mid y \mid x$, where $y = xU$ and U a unit. So for a prime $p$, one can use $pU$ as a representative value of it. In the integers, $U = \pm 1$. $\endgroup$ – wendy.krieger Aug 5 '13 at 8:05
  • 2
    $\begingroup$ The sentence «A prime number like 7 represents all of the values that both divide 7 and are multiples of it» is quite confused. The number seven does not represent anything... $\endgroup$ – Mariano Suárez-Álvarez Jan 5 '14 at 19:11
  • $\begingroup$ It is the numeral $7$ that represents a particular number, while the numeral $-7$ represents the opposite or additive inverse of $7$. $\endgroup$ – user 726941 Jan 5 '14 at 20:21
  • $\begingroup$ For the set N, all primes are positive, because the set itself is positive. But you have sets with negative numbers, and then one can use either 7 or -7 as a possible representive. Gauss law of quadratic recriprolity puts all primes >2 as $1 \pmod{4}$, so half the primes are negative. In other integer systems, numbers like 2 and 3 are composite, the is no unique representation of the primes involved because of multiple units. $\endgroup$ – wendy.krieger Jan 7 '14 at 3:40

Please refer to the below link:


I think this explains the best.

  • 11
    $\begingroup$ Please avoid link only answers $\endgroup$ – Alice Ryhl Sep 8 '14 at 16:55
  • $\begingroup$ Does it really matter? I think people should only be bothered about knowledge & i don't know why are you saying this. But if there is any genuine reason, do mention @Darksonn $\endgroup$ – bivs06 Sep 9 '14 at 21:03
  • $\begingroup$ @bivso6 Please see the help center and also this meta thread $\endgroup$ – Alice Ryhl Sep 10 '14 at 6:02
  • 3
    $\begingroup$ If links really helped, math.SE would not have existed. Don't take anyone wrong, but the idea is get the knowledge from the link, understand it, transform it and reproduce here on math.SE like an answer. $\endgroup$ – MonK Apr 29 '15 at 12:13

Primes are always modulo units in algebra. For example, let $p(x)$ with coefficients in $\mathbb{R}$ be a polynomial that can not be divided by any other polynomial over $\mathbb{R}$. Then $a\cdot p(x)$ is prime for all $a\in \mathbb{R}$, $a\ne 0$.

A unit is an element with inverse, in this case $a$ is a unit-polynomial.


Not the answer you're looking for? Browse other questions tagged or ask your own question.