Pernicious Number Calculator
Check whether the number of ones in the binary form of n is itself a prime number.
What it does
A pernicious number is a positive integer whose binary expansion contains a prime number of ones. The sequence begins 3, 5, 6, 7, 9, 10, 11, 12 and 13. Three has two binary ones, and two is prime, so it is pernicious.
The name was coined by John Conway, who used it in a proof that every positive integer has a multiple that is pernicious. The property combines a bitwise count with an ordinary primality test.
This page converts the input to binary, counts the ones and tests that small count for primality. The binary string is printed so the count can be verified independently.
Because the count is small even for large inputs, the primality test is immediate. A step guard and a bounded binary conversion keep the whole computation safe.
The input limit is one trillion, which keeps the printed bit string manageable and the result exact.
How to use
- Enter a whole number n from 0 to 1,000,000,000,000.
- Read the classification in the main result box.
- Check the binary expansion beside it.
- Count the ones and test that number for primality.
- The default n = 3 reproduces the worked example.
- Try n = 7 to see three binary ones, which is also prime.
Formula
- n
- The nonnegative integer being classified.
- binary
- The base 2 expansion of n.
- ones
- The count of binary ones, which must be prime.
Counts of zero and one are not prime, so 0 and 1 fail. Counts of two, three, five and seven are the most common qualifying values for modest inputs. The primality test is exact.
Worked example
Example: n = 3
The page opens with n = 3.
- Write 3 in binary: it is 11.
- Count the ones: there are two.
- Two is a prime number.
- The tool reports ones 2, binary 11, and Pernicious.
- For 7 the binary form is 111 with three ones, also prime.
- For 4 the binary form is 100 with one one, which is not prime.
Reference table
| n | Binary | Ones | Pernicious |
|---|---|---|---|
| 0 | 0 | 0 | No |
| 1 | 1 | 1 | No |
| 3 | 11 | 2 | Yes |
| 5 | 101 | 2 | Yes |
| 7 | 111 | 3 | Yes |
| 8 | 1000 | 1 | No |
Limits
- Only nonnegative integers are accepted.
- Inputs above one trillion are rejected to keep the bit string short.
- The classification is base 2 specific.
- The tool gives a verdict, not the position in the sequence.
Common mistakes
- Counting decimal digits instead of binary digits.
- Treating a count of one as prime.
- Assuming every number with two binary ones is small.
- Confusing this with evil or odious numbers.
- Including leading zeros in the count.
Try it yourself
Quick checks. Answers sit tucked under each question.
Is 3 pernicious?
Yes. Its binary form 11 has two ones, and two is prime.
Is 8 pernicious?
No. Its binary form 1000 has one one, which is not prime.
Is 7 pernicious?
Yes. Its binary form 111 has three ones.
Questions
Who named pernicious numbers?
The name is attributed to John Conway.
What is the connection to multiples?
Conway used the property in proving that every positive integer has a pernicious multiple.
Which counts qualify?
Prime counts such as 2, 3, 5 and 7.
Is one pernicious?
No, because its binary form has one one and one is not prime.
Are results exact?
Yes, binary conversion and primality are exact.
What input range is accepted?
Whole numbers from 0 through 1,000,000,000,000.