Evil Number

A number x in which the first n decimal digits of the fractional part frac(x) sum to 666 is known as an evil number (Pegg and Lomont 2004).

Binary plot

However, the term "evil" is also used to denote nonnegative integers that have an even number of 1s in their binary expansions, the first few of which are 0, 3, 5, 6, 9, 10, 12, 15, 17, 18, 20, ... (OEIS A001969), illustrated above as a binary plot. Numbers that are not evil are then known as odious numbers.

Returning to Pegg's definition of evil, the fact that pi is evil was noted by Keith, while I. Honig (pers. comm., May 9, 2004) noted that the golden ratio phi is also evil. The following table gives a list of some common evil numbers (Pegg and Lomont 2004).


The probability of the digits of a given real number summing to a relatively large positive integer is roughly given by the number of nonzero digits divided by sum of those digits, namely 9/(1+2+3+4+5+6+7+8+9)=1/5. Amazingly, the exact probability for summing to a number n can be computed exactly using the recursive formulas

p_n={1/9(1+sum_(k=1)^(n-1)p_k) for n<10; 1/9sum_(k=1)^(9)p_(k-n) for n>=10.

For n=1, 2, ..., the first few values are therefore 1/9, 10/81, 100/739, 1000/6561, ... (OEIS A100061 and A100062; Pegg and Lomont 2004), plotted above.

The generating function for this series is given by


(Pegg and Lomont 2004). This allows an expression for p_n to be determined in closed form, although it is a complicated expression involving combinations of the algebraic numbers (and polynomial roots) (1+2x+3x^2+4x^3+5x^4+6x^5+7x^6+8x^7+9x^8)_n.

For the case of interest (n=666), the result is a rational number having a 635-digit numerator and a 636-digit denominator that is approximately equal to

 p_(666) approx 1/5-2.1662×10^(-64).

A set of "beastly evil" numbers are given by the following (M. Hudson, pers. comm., Nov 5-10, 2004).


Powers of pi that are evil include n=1, 6, 8, 10, 17, 18, 24, 25, 26, 29, 30, 38, ... (M. Hudson, pers. comm., Nov. 8, 2004).

The analogous problem of terms in a simple continued fraction summing to a given number can also be considered. The following table summarized some constants whose continued fractions have cumulative sums that equal 666 (Pegg and Lomont 2004).

cube line picking average length50
pi pi56
Bloch constant58
Gauss's constant143
conjectured value of Landau constant173

Interestingly, this makes the cube line picking average length and pi doubly evil.

See also

Apocalypse Number, Beast Number, Economical Number, Happy Number, Lucky Number, Odious Number, Unhappy Number, Wasteful Number

Portions of this entry contributed by Mark Hudson

Explore with Wolfram|Alpha


Keith, M. "The Number of the Beast.", E. Jr. and Lomont, C. "Math Games: Evil Numbers." Oct. 4, 2004., N. J. A. Sequences A001969, A100061 and A100062 in "The On-Line Encyclopedia of Integer Sequences."

Referenced on Wolfram|Alpha

Evil Number

Cite this as:

Hudson, Mark and Weisstein, Eric W. "Evil Number." From MathWorld--A Wolfram Web Resource.

Subject classifications