-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvenDigitSum.java
More file actions
42 lines (40 loc) · 921 Bytes
/
EvenDigitSum.java
File metadata and controls
42 lines (40 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<<<<<<< HEAD
//2180. Count Integers With Even Digit Sum
class Solution {
public boolean digitSum(int n){
int sum = 0;
while(n>0){
sum += (n%10);
n/=10;
}
return sum%2 == 0;
}
public int countEven(int num) {
if(num==0) return 0;
int count = 0;
for(int i=1;i<=num;i++){
if(digitSum(i)) count ++;
}
return count;
}
=======
//2180. Count Integers With Even Digit Sum
class Solution {
public boolean digitSum(int n){
int sum = 0;
while(n>0){
sum += (n%10);
n/=10;
}
return sum%2 == 0;
}
public int countEven(int num) {
if(num==0) return 0;
int count = 0;
for(int i=1;i<=num;i++){
if(digitSum(i)) count ++;
}
return count;
}
>>>>>>> be6ce0b427078b1421d5dd74adb2300dc02daeec
}