Even or Odd Without Division
Updated
Problem statement
Given an integer n, return true if n is even and false if it is odd.
Practice rule: solve it without division and without the remainder operator (/ and % in most languages). The judge checks only the answer, so this rule is not enforced; it is the point of the exercise.
Negative numbers follow the usual rule: a number is even when it is 2 times some integer, so -4 and 0 are even and -7 is odd.
Function
isEven(n: int) → booleanExamples
Example 1
n = 14return = true14 is 2 times 7, so it is even. The answer is true.
Example 2
n = -9return = false-9 lies between -10 and -8, two even numbers, so it is odd. The answer is false.
Example 3
n = -1073741824return = true-1073741824 is -2^30, which is 2 times -2^29, so it is even. The answer is true.
Constraints
-2^31 <= n <= 2^31 - 1
More Adobe Phone Screen questions
- Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
- All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
- Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
- Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
- Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
- Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026
Similar questions at other companies
- Count the 1 Bits in a 32-Bit ValueAmazon · PHONE SCREEN
- Power of Two Without DivisionArm · PHONE SCREEN
- Powers of Two in a RangeAkuna Capital · PHONE SCREENAkuna Capital interview questions
- Choose the Next Minesweeper ActionRunloop · PHONE SCREEN
- IP Address to CIDR BlocksOpenAI · PHONE SCREENOpenAI interview questions
- Fewest Games to Find the Top Two TeamsSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
- Minimum Testers to Find the Poisoned BottleWalleye Capital · OA
- Address on Same PageNVIDIA · OANVIDIA interview questions
- Find the Missing Number from 1 to nHyperVerge · ONSITE INTERVIEW
- Find the Missing Number from 1 to nGEP · OA
Interview reports that mention this question
Adobe interview experiences
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)