Class Solution
java.lang.Object
g2401_2500.s2427_number_of_common_factors.Solution
2427 - Number of Common Factors.<p>Easy</p>
<p>Given two positive integers <code>a</code> and <code>b</code>, return <em>the number of <strong>common</strong> factors of</em> <code>a</code> <em>and</em> <code>b</code>.</p>
<p>An integer <code>x</code> is a <strong>common factor</strong> of <code>a</code> and <code>b</code> if <code>x</code> divides both <code>a</code> and <code>b</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> a = 12, b = 6</p>
<p><strong>Output:</strong> 4</p>
<p><strong>Explanation:</strong> The common factors of 12 and 6 are 1, 2, 3, 6.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> a = 25, b = 30</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> The common factors of 25 and 30 are 1, 5.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= a, b <= 1000</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
commonFactors
public int commonFactors(int a, int b)
-