FastPrepDivisibility by Three and Five
Problems/Divisibility by Three and Five

Divisibility by Three and Five

JP Morgan Chase logoJP Morgan Chase● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a JP Morgan Chase intern online assessment. The report describes classifying one number by whether 3 and 5 divide it. It does not give the exact labels or the limits on the input. Our version is about 95% the same as the reported task.

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) → String

Examples

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

Interview reports that mention this question

  • JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)

JP Morgan Chase interview experiences

  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
  • JPMorgan Code for Good India: 10 Experiences (Part 4 of 5)
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights
Saved
class Solution {
    public String classifyDivisibility(int number) {
        // Write your code here.
    }
}
Checking account…