# Pernicious number

Short description: Number with prime Hamming weight

In number theory, a pernicious number is a positive integer such that the Hamming weight of its binary representation is prime, that is, there is a prime number of 1s when it is written as a binary number.

## Examples

The first pernicious number is 3, since 3 = 112 and 1 + 1 = 2, which is a prime. The next pernicious number is 5, since 5 = 1012, followed by 6 (1102), 7 (1112) and 9 (10012). The sequence of pernicious numbers begins

3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 22, 24, ... (sequence A052294 in the OEIS).

## Properties

No power of two is a pernicious number. This is trivially true, because powers of two in binary form are represented as a one followed by zeros. So each power of two has a Hamming weight of one, and one is not considered to be a prime. On the other hand, every number of the form $\displaystyle{ 2^n+1 }$ with $\displaystyle{ n\gt 1 }$, including every Fermat number, is a pernicious number. This is because the sum of the digits in binary form is 2, which is a prime number.

A Mersenne number $\displaystyle{ 2^n-1 }$ has a binary representation consisting of $\displaystyle{ n }$ ones, and is pernicious when $\displaystyle{ n }$ is prime. Every Mersenne prime is a Mersenne number for prime $\displaystyle{ n }$, and is therefore pernicious. By the Euclid–Euler theorem, the even perfect numbers take the form $\displaystyle{ 2^{n-1}(2^n-1) }$ for a Mersenne prime $\displaystyle{ 2^n-1 }$; the binary representation of such a number consists of a prime number $\displaystyle{ n }$ of ones, followed by $\displaystyle{ n-1 }$ zeros. Therefore, every even perfect number is pernicious.

## Related numbers

• Odious numbers are numbers with an odd number of 1s in their binary expansion ().
• Evil numbers are numbers with an even number of 1s in their binary expansion ().