Skip to content

Commit d1dc867

Browse files
authored
Create 1837. Sum of Digits in Base K.py
1 parent 01b2db7 commit d1dc867

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def sumBase(self, n: int, k: int) -> int:
3+
ans = 0
4+
5+
while n:
6+
n, r = divmod(n, k)
7+
ans += r
8+
9+
return ans

0 commit comments

Comments
 (0)