Pernicious Number Calculator

Number

Is 12 a pernicious number?Yes - its binary form has 2 ones, and 2 is prime
Binary form1100
Number of 1 bits2
Next pernicious number after 1213
How this was calculated
  1. A pernicious number is a positive integer whose binary form contains a prime number of 1 bits.
  2. In binary, 12 is 1100, which has 2 ones.
  3. The count 2 is prime, so the test is passed.
  4. So 12 is pernicious; the next pernicious number is 13.

A pernicious number is a positive integer whose binary expansion has a prime number of 1 bits — a prime population count, or popcount. This pernicious number calculator checks any positive integer you enter and tells you whether it is pernicious. It converts your number to binary, counts the 1 bits, and tests whether that count is prime. For example, 12 in binary is 1100, which has 2 one-bits, and 2 is prime, so 12 is pernicious; the next pernicious number after 12 is 13. Likewise, 17 in binary is 10001, which has 2 one-bits, so 17 is pernicious; the next pernicious number after 17 is 18. By contrast, 15 in binary is 1111, which has 4 one-bits, and 4 is not prime, so 15 is not pernicious; the next pernicious number after 15 is 17.

The method behind the calculator is the definition itself: write the number in binary, count the 1 bits, and check whether that count is prime. That is the accepted standard for identifying pernicious numbers, and the tool applies it directly rather than relying on a lookup table. The definition also explains two useful patterns. No power of two can be pernicious, because its binary form has exactly one 1 bit and 1 is not prime. Every Mersenne number 2^p - 1 with p prime is pernicious. This page shows the formula, step-by-step workings, worked examples and sources so you can follow each result and verify it yourself.

Worked examples

12 in binary is 1100

(12)

Is 12 a pernicious number?Yes - its binary form has 2 ones, and 2 is prime
Binary form1100
Number of 1 bits2
Next pernicious number after 1213

17 in binary is 10001

(17)

Is 17 a pernicious number?Yes - its binary form has 2 ones, and 2 is prime
Binary form10001
Number of 1 bits2
Next pernicious number after 1718

15 in binary is 1111 - four ones

(15)

Is 15 a pernicious number?No - its binary form has 4 ones, and 4 is not prime
Binary form1111
Number of 1 bits4
Next pernicious number after 1517

What a pernicious number is

A pernicious number is a positive integer whose binary expansion has a prime number of 1 bits — a prime population count, or popcount. That single rule is the whole definition. Write the number in base 2, count the ones, and check whether that count is prime. If it is, the number is pernicious; if it is not, the number is not. Nothing about the size of the number, its divisibility, or its decimal digits matters — only the tally of 1 bits in its binary form. A pernicious number calculator applies exactly this test, so every result it gives can be verified by hand with a binary expansion and a short count.

The examples make the rule concrete. Twelve in binary is 1100, which has 2 one-bits, and 2 is prime, so 12 is pernicious; the next pernicious number after 12 is 13. Seventeen in binary is 10001, which has 2 one-bits, so 17 is pernicious; the next pernicious number after 17 is 18. Fifteen shows the other side of the test: 15 in binary is 1111, which has 4 one-bits, and 4 is not prime, so 15 is not pernicious; the next pernicious number after 15 is 17. Notice that the property does not run in blocks or follow the decimal order in any simple way — 15 fails while 12, 13, 17 and 18 pass.

Two structural facts follow directly from the definition. No power of two can be pernicious, because its binary form has exactly one 1 bit and 1 is not prime. So 1, 2, 4, 8, 16, 32 and every other power of two are excluded no matter how large they get. On the other hand, every Mersenne number 2^p - 1 with p prime is pernicious. A Mersenne number of that form is a string of p one-bits, so its popcount is p itself, and p is prime by assumption — the test passes automatically.

The term "pernicious" is a play on words rather than a description of danger; it labels a number by a property of its binary digits, not by anything harmful. Because the check depends only on the count of 1 bits, the same count can be shared by many numbers of very different sizes, and a number's pernicious status can change completely when a single bit is added or removed. That is why working through a binary expansion by hand is the clearest way to confirm any answer, and why a pernicious number calculator is useful for longer binary strings where counting ones by eye becomes error-prone.

To test any candidate yourself, convert it to binary, count the 1s, and ask whether that count is prime. The possible counts are small — 2, 3, 5, 7, 11 and so on — so the primality check is quick. If the count is 1 or a composite such as 4, 6, 8, 9 or 10, the number is not pernicious.

Quick rule: binary 1100 (12) has 2 one-bits and 2 is prime, so 12 is pernicious. Binary 1111 (15) has 4 one-bits and 4 is not prime, so 15 is not.

Counting the one-bits

The heart of a pernicious number calculator is a single, simple task: counting the one-bits in a number's binary expansion. A pernicious number is a positive integer whose binary expansion has a prime number of 1 bits — a prime population count, or popcount. So the calculator writes the number in base two, counts the 1s, and then checks whether that count is prime. Everything else follows from that count.

Take 12. In binary, 12 is 1100. Reading the digits left to right, you find a 1, another 1, then two zeros — so there are 2 one-bits. Since 2 is prime, 12 is pernicious, and the next pernicious number after 12 is 13. Now take 17. Its binary form is 10001: a leading 1, three zeros, and a final 1, which again gives 2 one-bits. Because 2 is prime, 17 is pernicious, and the next pernicious number after 17 is 18. The pattern is the same in both cases even though the numbers look very different in binary — the count is what matters, not the length of the expansion.

Contrast that with 15. In binary, 15 is 1111, four one-bits in a row. The count is 4, and 4 is not prime, so 15 is not pernicious. The next pernicious number after 15 is 17. This example shows why you cannot judge a number by how many 1s it seems to have at a glance: 1111 is dense with ones, but a popcount of 4 fails the prime test. A pernicious number calculator handles this check for you, but the reasoning is exactly the bit-by-bit count shown here.

Two edge cases round out the counting rule. No power of two can be pernicious, because its binary form has exactly one 1 bit, and 1 is not prime. Every Mersenne number 2^p - 1 with p prime is pernicious — its binary form is p ones, and p is prime by definition. The table below collects the worked examples from this section.

NumberBinaryOne-bits (popcount)Is the count prime?Pernicious?Next pernicious number
1211002YesYes13
17100012YesYes18
1511114NoNo17
Count the 1s first, then test that count for primality: 12 gives 2 (prime, pernicious), 17 gives 2 (prime, pernicious), 15 gives 4 (not prime, not pernicious).

Powers of two and Mersenne numbers

A power of two is the simplest kind of number in binary: it is a single 1 followed by zeros. The number 1 is 1, 2 is 10, 4 is 100, 8 is 1000, and so on. In every case the binary expansion contains exactly one 1 bit. That gives a population count — popcount for short — of 1. A pernicious number is defined as a positive integer whose binary expansion has a prime number of 1 bits, so the popcount must itself be prime. The number 1 is not prime, which means no power of two can ever qualify. The popcount is always 1, and 1 fails the test every time, no matter how large the power of two becomes. This is one of the quickest checks a pernicious number calculator can make: if a number is a power of two, it is not pernicious, and there is no need to count further.

Mersenne numbers behave in the opposite way. A Mersenne number has the form 2^p - 1, and in binary it is p ones in a row. For example, 2^3 - 1 = 7 is 111, and 2^5 - 1 = 31 is 11111. The popcount of 2^p - 1 is exactly p, because every bit position is filled with a 1. So the question of whether a Mersenne number is pernicious reduces to a question about p: is p prime? When p is prime, the popcount is prime, and the Mersenne number is pernicious. Every Mersenne number 2^p - 1 with p prime therefore qualifies. This gives a clean family of pernicious numbers that can be written down directly, without counting bits one at a time.

Contrast this with a number like 15, which is 1111 in binary. It has 4 one-bits, and 4 is not prime, so 15 is not pernicious. The next pernicious number after 15 is 17, whose binary form 10001 has 2 one-bits, and 2 is prime. Small examples like these show how the popcount rule works in practice. The power-of-two case is the extreme low end of the count — a single 1 bit — while the Mersenne case with prime p pushes the count up to p itself. Between them, these two families cover the simplest patterns of binary digits and give useful reference points when you are checking results from a pernicious number calculator.

It is worth being precise about the Mersenne claim. The rule is stated for 2^p - 1 where p is prime. If p is not prime, the popcount is not prime, and the number is not pernicious by this argument. The rule does not say anything about whether the Mersenne number itself is prime; it is purely about the count of 1 bits. A number such as 12, which is 1100 with 2 one-bits, is pernicious because 2 is prime, and the next pernicious number after 12 is 13. These examples sit alongside the power-of-two and Mersenne families as illustrations of the same underlying test: count the ones, then check whether that count is prime.

Quick rule: a power of two has popcount 1, and 1 is not prime, so it is never pernicious. A Mersenne number 2^p - 1 has popcount p, so it is pernicious exactly when p is prime.

A whimsical name with real uses

"Pernicious" sounds like a word invented for a fairy tale villain, but it is a precise mathematical label. A pernicious number is a positive integer whose binary expansion has a prime number of 1 bits — in other words, a prime population count, or popcount. The name is playful; the property it describes is a straightforward count of set bits, which is exactly the kind of thing a pernicious number calculator checks in an instant.

The label is easier to trust once you run a few examples by hand. Twelve in binary is 1100, which has 2 one-bits, and 2 is prime, so 12 is pernicious; the next pernicious number after 12 is 13. Seventeen in binary is 10001, which has 2 one-bits, so 17 is pernicious; the next pernicious number after 17 is 18. Fifteen in binary is 1111, which has 4 one-bits, and 4 is not prime, so 15 is not pernicious; the next pernicious number after 15 is 17. Two structural facts follow: no power of two can be pernicious, because its binary form has exactly one 1 bit and 1 is not prime; and every Mersenne number 2^p - 1 with p prime is pernicious.

Popcount is not a curiosity confined to number puzzles. In computing, the number of 1 bits in a binary word is called its Hamming weight, and it shows up wherever a program needs to measure how many positions differ or how many features are switched on. Bit tricks lean on it constantly: counting set bits in a bitmask, testing whether a value is a power of two, or scoring similarity between two binary strings all reduce to popcount. Processors often expose it directly as a single instruction, which is a strong hint at how routine the operation is.

Cryptography and coding make heavier use of the same count. Hamming weight feeds into error-detecting and error-correcting codes, where the distance between two bit strings is the number of positions in which they differ. In cryptographic contexts, balanced Hamming weights and popcount-style measurements appear in the analysis of keys and in constant-time bit-manipulation routines. None of this makes pernicious numbers themselves a security tool, but it explains why the popcount at their heart is worth understanding. A pernicious number calculator simply turns that everyday computing primitive into a small, checkable property of the integers.

The whimsy is all in the name: underneath it sits popcount, the same count of 1 bits that processors compute in a single instruction.

FAQs

Is 12 a pernicious number?

Yes. Twelve is 1100 in binary, and that binary form contains 2 one-bits. Because 2 is a prime number, 12 meets the definition of a pernicious number: a positive integer whose binary representation has a prime number of 1 bits. So 12 counts as pernicious.

Is 15 a pernicious number?

No. Fifteen is 1111 in binary, which gives 4 one-bits. Since 4 is not a prime number, the count of one-bits fails the pernicious test. That is why 15 is not pernicious, even though its binary form is made entirely of ones.

How many one-bits does 17 have in binary?

Seventeen has 2 one-bits. In binary, 17 is written as 10001, so there is a single 1 at each end and zeros in between. Because 2 is prime, 17 is pernicious. The count of one-bits, not the value of the number, decides the classification.

What is the next pernicious number after 15?

The next pernicious number after 15 is 17. Fifteen itself is not pernicious, since its 1111 binary form has 4 one-bits and 4 is not prime. Sixteen is a power of two, so it has only one 1 bit. Seventeen, written 10001, has 2 one-bits, and 2 is prime.

Can a power of two be pernicious?

No. A power of two has a binary form with exactly one 1 bit and zeros everywhere else. That means its count of one-bits is 1, and 1 is not a prime number. Since the count must be prime, no power of two can be pernicious, no matter how large the exponent is.

Are Mersenne numbers pernicious?

Yes, when the exponent p is prime. A Mersenne number has the form 2^p - 1, and its binary form is p one-bits in a row. So it has exactly p one-bits. If p is prime, that count is prime, and the Mersenne number is pernicious. If p is not prime, the count is not prime.

Sources

Related calculators

Hamming Distance Calculator
Hamming distance between two whole numbers: the bit positions that differ, shown as aligned binary strings with the XOR value and the set-bit counts of both numbers.
Number Base Converter
Number base converter: a decimal number in binary, octal and hexadecimal, with the bits and bytes it needs.
Binary Converter Calculator
Convert decimal numbers to binary, octal and hexadecimal — or read binary and octal numbers back into decimal — with the place-value working shown.