Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d7f5a54

Browse files
feat: add typescript solution to lc problem: No.2427
No.2427.Number of Common Factors
1 parent 1240ef1 commit d7f5a54

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

‎solution/2400-2499/2427.Number of Common Factors/README.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,14 @@ func commonFactors(a int, b int) int {
108108
### **TypeScript**
109109

110110
```ts
111-
111+
function commonFactors(a: number, b: number): number {
112+
const n = Math.min(a, b);
113+
let ans = 0;
114+
for (let i = 1; i <= n; i++) {
115+
if(a % i == 0 && b % i == 0) ans += 1;
116+
}
117+
return ans;
118+
};
112119
```
113120

114121
### **...**

‎solution/2400-2499/2427.Number of Common Factors/README_EN.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,14 @@ func commonFactors(a int, b int) int {
9595
### **TypeScript**
9696

9797
```ts
98-
98+
function commonFactors(a: number, b: number): number {
99+
const n = Math.min(a, b);
100+
let ans = 0;
101+
for (let i = 1; i <= n; i++) {
102+
if(a % i == 0 && b % i == 0) ans += 1;
103+
}
104+
return ans;
105+
};
99106
```
100107

101108
### **...**
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function commonFactors(a: number, b: number): number {
2+
const n = Math.min(a, b);
3+
let ans = 0;
4+
for (let i = 1; i <= n; i++) {
5+
if(a % i == 0 && b % i == 0) ans += 1;
6+
}
7+
return ans;
8+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /