-
-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy path258.java
More file actions
27 lines (27 loc) · 751 Bytes
/
258.java
File metadata and controls
27 lines (27 loc) · 751 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
__________________________________________________________________________________________________
sample 0 ms submission
class Solution {
public int addDigits(int num) {
while(num>=10){
num=(num-1)%9+1;
}
return num;
}
}
__________________________________________________________________________________________________
sample 32080 kb submission
class Solution {
public int addDigits(int num) {
int a;
while(num>9){
a=0;
while(num>0){
a+=num%10;
num=num/10;
}
num=a;
}
return num;
}
}
__________________________________________________________________________________________________