2427. Number of Common Factors Easy

@problem@discussion
#Math#Enumeration#Number Theory



1/**
2 * [2427] Number of Common Factors
3 *
4 * Given two positive integers a and b, return the number of common factors of a and b.
5 * An integer x is a common factor of a and b if x divides both a and b.
6 *  
7 * Example 1:
8 * 
9 * Input: a = 12, b = 6
10 * Output: 4
11 * Explanation: The common factors of 12 and 6 are 1, 2, 3, 6.
12 * 
13 * Example 2:
14 * 
15 * Input: a = 25, b = 30
16 * Output: 2
17 * Explanation: The common factors of 25 and 30 are 1, 5.
18 * 
19 *  
20 * Constraints:
21 * 
22 * 	1 <= a, b <= 1000
23 * 
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/number-of-common-factors/
28// discuss: https://leetcode.com/problems/number-of-common-factors/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33    pub fn common_factors(a: i32, b: i32) -> i32 {
34        0
35    }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42    use super::*;
43
44    #[test]
45    fn test_2427() {
46    }
47}
48


Back
© 2025 bowen.ge All Rights Reserved.