An integer is odd when it is not divisible by 2. Equivalently, n % 2 is not 0.
Remember
n is odd ⇔ n % 2 != 0
Examples:
11 % 2 = 1 → odd
7 % 2 = 1 → odd
10 % 2 = 0 → even (not odd)
0 % 2 = 0 → even (not odd)
n
n % 2
Result
11
1
Odd
10
0
Even
0
0
Even
-5
1
Odd
Approach
How to Check an Odd Number in Python
Four clear steps — then pick modulo, bitwise, or a step-by-two range loop.
Read the integer n (positive, negative, or zero).
Compute n % 2 (or check the least significant bit with n & 1).
If the remainder is not 0 (or the LSB is 1), n is odd.
To list odds in a range, test each value — or start at the first odd and add 2.
Method
Idea
Time
Best for
Modulo
n % 2 != 0
O(1)
Interviews, clearest logic
Bitwise
(n & 1) != 0
O(1)
Optional follow-up, LSB check
Step by 2
Start at first odd, add 2
O(N/2)
Listing odds in a range
Pseudocode
Pseudocode
function IsOdd(n):
return (n mod 2) != 0
function PrintOdds(start, end):
for i from start to end:
if IsOdd(i):
output i
// Faster range listing:
function PrintOddsStep(start, end):
i = start
if i is even:
i = i + 1
while i <= end:
output i
i = i + 2
Reference
Cheat Sheet
Keep these facts handy while writing the program.
Topic
Detail
Odd test
n % 2 != 0
Even test
n % 2 == 0
Bitwise odd
(n & 1) != 0
Zero
0 is even — not odd
Negatives
-5 is odd; -4 is even
Classic check
11 → odd; 10 → even
Try it
Live Preview
Enter any integer to see the remainder and the odd/even verdict.
Whole numbers only. Tap a chip or type a value.
Result
n = 11
n % 2 = 1
(n & 1) = 1
Verdict: ODD
Trace
Worked Walkthrough — n = 11
Apply the modulo rule, then confirm with the bitwise check.
Calculation
Step 1: Compute 11 % 2
11 = 2 * 5 + 1
remainder = 1
Step 2: Remainder is not 0 → odd
Step 3: Bitwise check
11 in binary ends with 1
(11 & 1) = 1 → same answer
Verdict: 11 is odd
Code
Python Programs
Start with the modulo helper — it is the clearest interview answer. Then reuse it for a range, and finish with the bitwise shortcut.
Example 1 — Modulo Check
Return True when the remainder by 2 is not zero.
python
def is_odd(n):
return n % 2 != 0
number = 11
if is_odd(number):
print(f"{number} is an odd number.")
else:
print(f"{number} is not an odd number.")
Output
11 is an odd number.
How It Works
is_odd computes n % 2 and checks that it is not 0.
For 11, the remainder is 1, so the function returns True.
The call site prints the matching message based on that boolean.
Swap 11 for 10 to see the even (not odd) path.
This is the default answer to give in interviews — clear and correct.
Example 2 — Odds in a Range
Reuse the helper to print every odd value from 1 to 10.
python
def is_odd(n):
return n % 2 != 0
start = 1
end = 10
print(f"Odd numbers from {start} to {end}:")
for i in range(start, end + 1):
if is_odd(i):
print(i, end=" ")
print()
Output
Odd numbers from 1 to 10:
1 3 5 7 9
How It Works
range(start, end + 1) walks every integer from start through end inclusive.
Each i is tested with is_odd.
Only odd values are printed: 1 3 5 7 9.
Even values like 2, 4, and 6 are skipped.
For large ranges, start at the first odd and use a step of 2 instead of testing every integer.
Example 3 — Bitwise Check
Odd integers have a least significant bit of 1, so n & 1 is not 0.
python
def is_odd_bitwise(n):
return (n & 1) != 0
samples = [11, 10, 0, -5]
for n in samples:
label = "odd" if is_odd_bitwise(n) else "even"
print(f"{n}: {label}")
Output
11: odd
10: even
0: even
-5: odd
How It Works
n & 1 keeps only the least significant bit.
If that bit is 1, the number is odd; if 0, it is even.
The sample list shows positives, zero, and a negative odd value.
Results match the modulo method for these integers.
Prefer modulo in interviews for readability; mention bitwise as a follow-up.
Edge Cases & Pitfalls
Check these before calling the solution done.
Zero
0 is not odd
0 % 2 == 0, so zero is even. Do not treat it as “neither.”
Negatives
Parity still applies
In Python, -5 % 2 is 1 — still nonzero, so still odd under != 0.
Floats
Use integers
Odd/even is defined for integers. Do not apply % 2 to floats without a clear rule.
Range
Inclusive bounds
Use range(start, end + 1) when both ends should be checked. Off-by-one errors drop the last odd.
Analysis
Time and Space Complexity
Program
Time
Extra space
Modulo / bitwise check
O(1)
O(1)
Scan range of size N
O(N)
O(1)
Step-by-two listing
O(N/2)
O(1)
A single parity test is constant time. Range printers grow with how many integers you visit.