#2427

Number of Common Factors

newbie · 175 · lc easy +15 · verified · 79.9% accepted · 681 likes · top 91%

Description

Given two positive integers a and b, return the count of integers in the range [1, min(a, b)] that are common divisors of both a and b.

Example 1:

Input: a = 12, b = 6
Output: 4
Explanation: The common factors of 12 and 6 are 1, 2, 3, 6.

Example 2:

Input: a = 25, b = 30
Output: 2
Explanation: The common factors of 25 and 30 are 1, 5.

Code

1
2
3