Skip to content

Commit b4903e9

Browse files
committed
feat: add typescript solution to lc problem: No.2180
No.2180.Count Integers With Even Digit Sum
1 parent 475d2a1 commit b4903e9

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

solution/2100-2199/2180.Count Integers With Even Digit Sum/README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,15 @@
6464
### **TypeScript**
6565

6666
```ts
67-
67+
function countEven(num: number): number {
68+
let ans = 0;
69+
for (let i = 2; i <= num; i++) {
70+
if ([...String(i)].reduce((a, c) => a + Number(c), 0) % 2 == 0) {
71+
ans++;
72+
}
73+
}
74+
return ans;
75+
};
6876
```
6977

7078
### **...**

solution/2100-2199/2180.Count Integers With Even Digit Sum/README_EN.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,15 @@ The 14 integers less than or equal to 30 whose digit sums are even are
5454
### **TypeScript**
5555

5656
```ts
57-
57+
function countEven(num: number): number {
58+
let ans = 0;
59+
for (let i = 2; i <= num; i++) {
60+
if ([...String(i)].reduce((a, c) => a + Number(c), 0) % 2 == 0) {
61+
ans++;
62+
}
63+
}
64+
return ans;
65+
};
5866
```
5967

6068
### **...**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function countEven(num: number): number {
2+
let ans = 0;
3+
for (let i = 2; i <= num; i++) {
4+
if ([...String(i)].reduce((a, c) => a + Number(c), 0) % 2 == 0) {
5+
ans++;
6+
}
7+
}
8+
return ans;
9+
};

0 commit comments

Comments
 (0)