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
Run — free
Worked example
- N
- 3
- 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.
What you can do with it
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.
FAQ
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.
Related tools
For developers — API access
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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/numth/evil-number \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":3}'const res = await fetch("https://api.kit.forhosting.com/numth/evil-number", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 3
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/evil-number",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 3
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/evil-number", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":3}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":3}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/evil-number", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"n": 3
}Example response
{
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
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.
Integration use cases
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.
Technical questions
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.