File tree 3 files changed +27
-2
lines changed
solution/2100-2199/2180.Count Integers With Even Digit Sum
3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 64
64
### ** TypeScript**
65
65
66
66
``` 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
+ };
68
76
```
69
77
70
78
### ** ...**
Original file line number Diff line number Diff line change @@ -54,7 +54,15 @@ The 14 integers less than or equal to 30 whose digit sums are even are
54
54
### ** TypeScript**
55
55
56
56
``` 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
+ };
58
66
```
59
67
60
68
### ** ...**
Original file line number Diff line number Diff line change
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
+ } ;
You can’t perform that action at this time.
0 commit comments