File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 281
281
2099|[ Find Subsequence of Length K With the Largest Sum] ( ./2099-find-subsequence-of-length-k-with-the-largest-sum.js ) |Medium|
282
282
2114|[ Maximum Number of Words Found in Sentences] ( ./2114-maximum-number-of-words-found-in-sentences.js ) |Easy|
283
283
2129|[ Capitalize the Title] ( ./2129-capitalize-the-title.js ) |Easy|
284
+ 2427|[ Number of Common Factors] ( ./2427-number-of-common-factors.js ) |Easy|
284
285
285
286
## License
286
287
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 2427. Number of Common Factors
3
+ * https://leetcode.com/problems/number-of-common-factors/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given two positive integers a and b, return the number of common factors of a and b.
7
+ *
8
+ * An integer x is a common factor of a and b if x divides both a and b.
9
+ */
10
+
11
+ /**
12
+ * @param {number } a
13
+ * @param {number } b
14
+ * @return {number }
15
+ */
16
+ var commonFactors = function ( a , b ) {
17
+ let count = 0 ;
18
+ for ( let i = Math . min ( a , b ) ; i > 0 ; i -- ) {
19
+ if ( a % i === 0 && b % i === 0 ) count ++ ;
20
+ }
21
+ return count ;
22
+ } ;
You can’t perform that action at this time.
0 commit comments