Problem Statement
A positive integer x is called a divisor of another positive integer y if y = xz for some integer z. For example, 1, 2, 3, 4, 6 and 12 are divisors of 12.
Let us measure the similarity of two numbers as the number of their common divisors.
You are given ints X and Y. Return their similarity.
Definition
- Class:
- SimilarNumbers
- Method:
- howSimilar
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int howSimilar(int X, int Y)
- (be sure your method is public)
Constraints
- X and Y will each be between 1 and 100000, inclusive.
Examples
12
14
Returns: 2
Common divisors of 12 and 14 are 1 and 2.30
24
Returns: 4
100000
99999
Returns: 1
55440
55440
Returns: 120
41405
74529
Returns: 9