Skip to content

Commit 3744abb

Browse files
authored
Added Sum of Digits in Base K.java
1 parent a886cc4 commit 3744abb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Easy/Sum of Digits in Base K.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public int sumBase(int n, int k) {
3+
int digitSum = 0;
4+
while (n > 0) {
5+
digitSum += n % k;
6+
n /= k;
7+
}
8+
return digitSum;
9+
}
10+
}

0 commit comments

Comments
 (0)