ForHosting KIT · Math

Evil number checker

3 is an evil number: in binary it is 11, with 2 ones, and 2 is even. Enter any non-negative whole number to see its binary form, how many ones it has and whether that count is even. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
N
3
You get
Binary
11
Ones count
2
Ones parity
even

An evil number is a non-negative integer whose binary representation contains an even count of one-bits. Zero is evil because its single binary digit is zero and the ones-count is even; three is evil because binary eleven has two ones; one is not evil because a single one is odd (that complementary class is often called odious). Negative inputs are rejected as invalid.

What an evil number is and how binary popcount decides it

Write any non-negative integer in base two and count how many digits equal one. If that population count—also called Hamming weight or set-bit count—is even, the integer is evil; if it is odd, the integer is odious and therefore not evil under this definition. The name comes from recreational number theory and pairs with the Thue–Morse sequence, where evil numbers sit at the even-parity positions.

Concrete cases help: zero has binary zero and zero ones, so it is evil; one has binary one and one one, so it is odious; two is binary ten with one one and is odious; three is binary eleven with two ones and is evil; four is binary one hundred with one one and is odious; five is binary one hundred one with two ones and is evil.

The definition is purely combinatorial on the bit string—it does not depend on prime factors, digit sums in base ten, or floating-point approximation. Teaching materials often contrast evil and odious numbers with perfect, abundant, or happy numbers: those properties inspect divisors or decimal digits, whereas evil status only inspects binary parity of ones.

Because every non-negative integer has a finite binary expansion, the property always terminates after a number of steps proportional to the bit length, which makes it ideal for automated checks, contest problems, coding interviews, and classroom demos where students must show the binary path rather than only a yes-or-no label.

Practical use, limits, pricing, and related searches

Use the browser tool when you want an immediate evil-number verdict while studying bit-parity problems, preparing a number-theory lesson, or checking a contest answer without installing a computer-algebra system. Accepted inputs are non-negative integers up to the JavaScript safe-integer maximum so classroom examples and interview demos stay exact inside ordinary number ranges. Results never depend on clocks, random seeds, or remote arithmetic services.

When teaching, prefer paired examples that show both outcomes: three and five as true evil cases, one and two as false odious cases, zero as the even-empty-ones edge case, and a negative input to demonstrate the hard rejection path. Sibling number-theory landings in this kit target other intents such as happy numbers, repunits, or prime checks; this page is specifically for people searching whether a given integer is an evil number or has even binary ones.

Classroom demos of binary Hamming weight

Teachers can show how even versus odd counts of one-bits separate evil from odious numbers, with every intermediate field visible for discussion.

What is an evil number?

A non-negative integer with an even number of ones in its binary representation. Example: 3 is binary 11 (two ones) so it is evil; 1 is binary 1 (one one) so it is not.

Is the evil number checker free?

The browser tool runs free on your device.

Are results deterministic?

There is no model, network call, or randomness in the path.

Is 3 an evil number?

Yes. Written in binary, 3 is 11, which has two ones. Two is an even count, so 3 is evil.

What is an odious number?

It is the opposite case: a number whose binary form has an odd count of ones, such as 1. Every non-negative whole number is either evil or odious, and the result shows the parity so you can see which.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/numth/evil-number

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/numth/evil-number \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"n":3}'
{
  "n": 3
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "numth.evil_number",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

This checker validates a non-negative integer, builds its binary string, counts set bits with pure integer arithmetic, and returns a clear boolean plus every intermediate field so students, teachers, and script authors can audit the classification without a computer-algebra system or opaque bit library.

What an evil number is and how binary popcount decides it

The complementary odious class is mentioned only for clarity; this capability answers the evil question and still reports ones_parity so you can see both sides of the coin in one response.

How this checker evaluates evil status and what the API returns

The implementation validates that n is present, finite, integral, and at least zero. Use it from homework pipelines, programming-contest validators, interview-prep sandboxes, or any workflow that needs a reproducible binary-parity check without installing specialized number-theory packages on every machine. Call the capability with a field n holding a non-negative integer, either as a JSON number within the safe integer range or as a plain digit string that normalizes to a whole integer. Aliases number and value are accepted for the same field. It then builds the binary representation without a 0b prefix (zero maps to the string zero), counts ones by repeatedly taking the least bit and integer-halving, and sets is_evil true when that count modulo two is zero. The response also returns ones_count, ones_parity as even or odd, binary as the bit string, and a short formula string that states popcount and the evil or odious conclusion. Missing n, non-integers, fractions, values above the published maximum, and any negative number fail with invalid_input and are not charged. Pricing is a flat $0.002 per successful request under the item unit.

Practical use, limits, pricing, and related searches

Each successful request is one billable item at $0.002; failed validation does not consume balance. Because binary and ones_count are returned together, students can recompute the popcount by hand and match the API line by line. Wire the endpoint into coding-interview practice apps, recreational math pages, integer classification pipelines, or teaching dashboards where you already prefer exact bit arithmetic over opaque black-box calculators. Delivery works from the web form, the task API, SDK clients, and other KIT channels without changing the mathematical contract.

Interview and contest bit-parity checks

Candidates and graders can verify evil-number classification for arbitrary non-negative integers and inspect binary and ones_count without writing a local popcount loop.

Automated integer classification pipelines

Scripts that tag integers by binary ones-parity can call a single deterministic item-priced endpoint instead of embedding ad hoc bit counting.

Is zero an evil number?

Yes. Zero has binary 0 and zero ones; zero is even, so is_evil is true.

What happens if n is negative?

The request fails with invalid_input. This checker requires a non-negative integer; negatives are rejected and not charged.

Read the full KIT documentation →