Skip to content

Commit 5d9d288

Browse files
Sum of Digits in Base K
1 parent e1d431b commit 5d9d288

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Python/1837.py

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

0 commit comments

Comments
 (0)