Evil Number Calculator
Check whether a number has an even count of ones in its binary expansion, with the bits shown.
What it does
An evil number is a nonnegative integer whose binary expansion contains an even number of ones. The sequence begins 0, 3, 5, 6, 9, 10 and 12. The name is a playful contrast with the odious numbers, which have an odd count of ones.
The classification depends on the binary representation, not on the decimal digits. Three is written 11 in binary, giving two ones, so it is evil. Seven is written 111, giving three ones, so it is not.
Evil and odious numbers appear in combinatorics and in the study of the Thue Morse sequence, where the parity of the binary digit sum determines each term. They also show up in the analysis of certain games and fair splitting problems.
This page converts the input to binary, counts the ones and reports the verdict together with the bit string so the count can be checked at a glance.
The input limit is one trillion. Binary conversion is exact and fast at that size, and the tool returns a clear error outside the range.
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 yourself to confirm the result.
- The default n = 3 reproduces the worked example.
- Try n = 7 to see a number that is not evil.
Formula
- n
- The nonnegative integer being classified.
- binary
- The base 2 expansion of n.
- ones
- The count of digit 1 in that expansion.
Zero is included and is evil, since its binary form has zero ones, an even number. The parity of the count is the only thing that matters, not the length of the binary string.
Worked example
Example: n = 3
The page opens with n = 3.
- Write 3 in binary: 3 = 11 in base 2.
- Count the ones: there are two.
- Two is an even number.
- The tool reports ones 2, binary 11, and Evil.
- For 7 the binary form is 111 with three ones, so the verdict would be Odious.
- For 0 the binary form is 0 with zero ones, so it is evil.
Reference table
| n | Binary | Ones | Evil |
|---|---|---|---|
| 0 | 0 | 0 | Yes |
| 1 | 1 | 1 | No |
| 3 | 11 | 2 | Yes |
| 5 | 101 | 2 | Yes |
| 6 | 110 | 2 | Yes |
| 7 | 111 | 3 | No |
Limits
- Only nonnegative integers are accepted.
- Inputs above one trillion are rejected to keep the printed value short.
- The classification is base 2 specific.
- The tool gives a verdict, not the position of n in the sequence.
Common mistakes
- Counting decimal digits instead of binary digits.
- Forgetting that zero is evil.
- Confusing evil with odious numbers.
- Assuming larger numbers must have more ones.
- Including leading zeros in the binary count.
Try it yourself
Quick checks. Answers sit tucked under each question.
Is 3 evil?
Yes. Its binary form 11 has two ones.
Is 7 evil?
No. Its binary form 111 has three ones, so it is odious.
Is 0 evil?
Yes, with zero ones.
Questions
What does evil mean here?
It is just a name for numbers with an even binary digit sum.
What is the opposite family?
Odious numbers have an odd number of ones.
Where do these appear?
In the Thue Morse sequence and problems about parity of digit sums.
Is zero included?
Yes, and it is evil.
Are results exact?
Yes, binary conversion is exact.
What input range is accepted?
Whole numbers from 0 through 1,000,000,000,000.