Divisibility by Three and Five
Updated
Problem statement
For the single integer number, return one label:
"both"if it is divisible by both 3 and 5."3"if it is divisible by 3 only."5"if it is divisible by 5 only."neither"otherwise.
An integer is divisible by a positive divisor when the remainder is zero. In particular, zero is divisible by both 3 and 5.
Function
classifyDivisibility(number: int) → StringExamples
Example 1
number = 15return = "both"15 = 3 * 5 and 15 = 5 * 3, so both divisibility conditions hold.
Example 2
number = 9return = "3"9 = 3 * 3, while its remainder on division by 5 is 4.
Constraints
-1000000000 <= number <= 1000000000
More JP Morgan Chase Online Assessment questions
- Find Total CostOA · Seen Oct 2026
- Minimum Meeting RoomsOA · Seen Oct 2026
- Count Dropped RequestsOA · Seen Oct 2026
- Maximize Minimum Deployment DifficultyOA · Seen Oct 2026
- Task SchedulingOA · Seen Oct 2026
- Substring RemovalOA · Seen Oct 2026
- Maximum Game Board ScoreOA · Seen Sep 2026
- Minimum Digit Changes Between String HalvesOA · Seen Sep 2026
- Same Substring Within BudgetOA · Seen Sep 2026
- Invert Ad Visibility BitsOA · Seen Aug 2026
Similar questions at other companies
- Count Valid Square PairsAuxoAI · OA
- Counting Cows by Their LegsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Server InvestmentRippling · OARippling interview questions
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Identification Number Check DigitAbridge · OAAbridge interview questions
- Count Substrings With Identical CharactersVirtu Financial · OAVirtu Financial interview questions
- Next Pascal Row CoefficientIntuit · OAIntuit interview questions
- Digit-Sum Sequence Join PointOpenAI · OAOpenAI interview questions
- Minimum Testers to Find the Poisoned BottleWalleye Capital · OA
- Address on Same PageNVIDIA · OANVIDIA interview questions