SERVIFY Hiring | Number of Common Factors | Off-Campus OA (2023)

Question · Posted Jun 2026

Problem: Number of Common Factors Given two positive integers a and b, return the number of common factors (divisors that divide both numbers). Example Input a = 12, b = 6 Output 4 Explanation Factors of 12: 1, 2, 3, 4, 6, 12 Factors of 6: 1, 2, 3, 6 Common factors: 1, 2, 3, 6 Total common factors = 4

The full answer & interview discussion are available to premium members.

Log in Create a free account