Ctrl K

Count Shared Divisors

Easy
You are given two positive integers x and y. Return how many positive integers divide both x and y evenly.
Example 1
x=18, y=24 → 4

Both numbers are divisible by 1, 2, 3 and 6: four shared divisors.

Example 2
x=9, y=16 → 1

The only shared divisor is 1.

Example 3
x=100, y=100 → 9
Constraints
  • 1 ≤ x, y ≤ 1000
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsA Trio of Divisors EasyWhere the Product Adds Up EasyPrimes Below a Bound MediumA Number as Two Primes MediumEven Vowel and Consonant Pieces Medium
loading Python…
Input
x=18, y=24
Expected
4

Run checks the first 3 tests in your browser. Submit checks all 102 tests on the server, hidden ones included.