P15331 [GeeksforGeeks] Common divisors4712
普及-
题目描述

Given two integer numbers a and b, the task is to find count of all common divisors of given numbers.
Example 1:
Input: a = 12, b = 24
Output: 6
Explanation: all common divisors
are 1, 2, 3, 4, 6 and 12.
Example 2:
Input: a = 3, b = 17
Output: 1
Explanation: all common divisors are 1.
Your Task:
You dont need to read input or print anything. Complete the function commDiv() which takes n as input parameter and returns the number of common divisors.
Expected Time Complexity: O(sqrt(n))
Expected Auxiliary Space: O(1)
Constraints:
1<= a,b <=1000

输入格式

见题面

输出格式

见题面

样例输入
a = 12, b = 24
样例输出
6