The concept of “evil” numbers in mathematics refers to certain integers that have an number of 1s in their binary expansion. In this article, we will take a deeper look at evil numbers, how they are defined, some examples, and interesting properties related to these numbers.

## Defining Evil Numbers

An evil number is defined as a nonnegative integer that has an even number of 1s in its binary expansion. Some key points about evil numbers:

- Evil numbers only include nonnegative integers greater than or equal to 0. Negative integers are not considered.
- The term “evil” does not imply anything negative or undesirable about these numbers mathematically. It is just a name to describe their binary properties.
- Having an even number of 1s means that when you write out the integer in binary (base 2), the total count of 1s in the expansion is divisible by 2.

Some simple examples will help illustrate the concept.

### Examples of Evil Numbers

Here are some small evil numbers and their binary expansions:

- 0 – Binary: 0
- 3 – Binary: 11 (2 1s)
- 5 – Binary: 101 (2 1s)
- 17 – Binary: 10001 (4 1s)

And some small non-evil numbers:

- 1 – Binary: 1 (1 1)
- 7 – Binary: 111 (3 1s)
- 15 – Binary: 1111 (4 1s)

As you can see, the key property that makes a evil is having a binary expansion with an even number of digit 1s. This comes up in interesting ways in higher mathematics.

## Odd Properties of Evil Numbers

While evil numbers may seem unremarkable at first glance, they have some fascinating and almost “spooky” mathematical properties. Here are some interesting facts about them:

### Sum of Consecutive Integers

One intriguing fact is that the sum of two consecutive evil numbers is always one less than a power of 2. For example:

17 (evil) + 18 (evil) = 35 Which is 1 less than 2^5 = 32

This works for all pairs of consecutive evil numbers, and is related to their binary expansions.

### Differences are Powers of 2

Also, the difference between any two consecutive evil numbers is always a power of 2. For example:

18 – 17 = 1 = 2^0 34 – 18 = 16 = 2^4

So evil numbers are always spaced exactly a power of 2 apart from their closest neighbors.

### Cycle Through Subsequent Values

Furthermore, as you increment through higher evil numbers, they cycle through all 2^k values as differences. The second difference is 2^1, third is 2^2, fourth is 2^3, and this pattern continues infinitely.

This property comes directly from the binary structure of evil numbers, but is unexplained “magic” at first encounter. Almost there is some hidden order even among the so-called evil numbers!

## Generating and Identifying Evil Numbers

While we have discussed some interesting patterns, how can we systematically generate evil numbers or test if a number is evil? Here are some methods:

### Check Binary Expansion

The most direct method is to convert the integer to binary and simply count the number of 1s. An even count means the number is evil. But this becomes impractical for large numbers.

### Modulo Method

There is an elegant formula using modular arithmetic:

A number n is evil if and only if n modulo 2^k yields n modulo 2, for ALL values of k≥1.

This provides a quick computational check for any suspected evil number.

### Closed Form Formula

There is also a closed form formula to generate the kth evil number:

kth evil number = (3 * 2^k) – 1 for k ≥ 0

So this produces the sequence 0, 3, 5, 17, 34, 65, … of evil numbers.

Easy to implement, though less intuitive than the modular test.

Both methods allow systematic generation of evil numbers up to any desired limit.

## Applications of Evil Numbers

On the surface, evil numbers seem abstract and almost contrived. But they do have some applications, for example in programming and cryptography.

### Hashing Functions

The unusual properties of evil numbers make them well-suited for certain hashing functions. These are used to map data to integer indexes in data structures and databases.

The evenly-spaced and ordered evil numbers can provide a good scattering distribution in a hash table. Their binary properties also give protection against certain cryptographic attacks.

### Random Number Generation

Similarly, evil numbers exhibit enough pattern for structure yet enough randomness to make them useful in generating pseudorandom sequences for simulations and video games.

The modular tests can be used to introduce apparent randomness, while maintaining some statistical structure due to their binary spacing.

### Educational Examples

Evil numbers are very approachable examples for introducing concepts like binary numbers, modular arithmetic, hash functions, and other computer science or discrete math topics to students.

The numbers are simple but lead to surprising insights, making them great educational tools.

While not applied directly, evil numbers illustrate in an accessible way how theoretical ideas get used broadly across mathematics and computer science. The behind-the-scenes value is in enriching education.

## Evil Numbers Popular Culture

Despite the technical mathematical origins, evil numbers have made some appearances in popular culture over the years:

### The Omen (1976 Film)

In the first Omen movie, the sinister child character Damien has an evil 666 birthmark. This matches the 666th evil number: 13,341,575,951,633,436,163. Possibly an eerie reference by the writer?

### Group 17 Album

The band Group 17 released an album called “37”, alluding to the 37th evil number of 13,834,190,265,461. Very niche choice! But shows digital properties creeping into art and culture.

### Crisis in Space App

An educational math app called “Crisis in Space” uses an evil number to introduce binary concepts, asking players to deactivate a forcefield by converting an evil number into decimal. Bringing some interest and applied learning!

While maybe not yet mainstream, evil numbers arise in neat ways that connect mathematics to the real world.

## FAQs

### What makes a number actually “evil”?

The term “evil” does not imply anything sinister or unlucky about these numbers. It simply refers to their property of having an even binary digit sum (an even number of 1s in their binary expansion). So it is more a quirk of mathematical naming conventions.

### Do evil numbers have any useful applications?

Yes, as mentioned evil numbers can play helpful roles in certain areas like hash functions, random number generation, and education. The structured yet unpredictable distribution of evil numbers provides value. They demonstrate how exotic theoretical ideas do find practical use.

### Are there other types of “odd” numbers similiar to evil numbers?

Certainly! For example odious numbers have an odd binary digit sum. There are also humorous numbers, untouchable numbers, and other classes defined by digit properties. Evil numbers became well-studied but belong to a family of curious mathematical sets.

### How are evil numbers generated or identified?

There are closed formulas for generating evil numbers, as well as modular arithmetic rules for testing if a number qualifies as evil. These provide efficient computational means to work with evil numbers.

### Do evil numbers have any surprising mathematical properties?

Yes, they exhibit some unintuitive and almost eerie patterns. For instance, the binary structure causes the differences between consecutive evil numbers to cycle through all powers of 2. And when summed, consecutive evil numbers yield one less then the next power of 2. Showing there is order amidst the oddity!

## Conclusion

In summary, while termed “evil”, these numbers are quite civil and tame! They have a precise mathematical definition related to binary expansions, but also exhibit special modular arithmetic properties. Evil numbers generate cyclical patterns that are fascinating mathematically, and even creep up occasionally in computer science and pop culture contexts. Rather than any negative connotations, evil numbers demonstrate that sometimes following mathematical curiosity reveals beauty and utility where least expected. Studying unusual numbers like these moves mathematics forward and keeps it vibrantly alive.