From faf33e9dd66ee0888188880a89d8a58e64dce61e Mon Sep 17 00:00:00 2001 From: ji-hyup Date: Mon, 7 Sep 2026 10:22:21 +0900 Subject: [PATCH] 1837 --- .../v3/1837. Sum of Digits in Base K.py" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "leetcode3/\353\263\200\354\247\200\355\230\221/v3/1837. Sum of Digits in Base K.py" diff --git "a/leetcode3/\353\263\200\354\247\200\355\230\221/v3/1837. Sum of Digits in Base K.py" "b/leetcode3/\353\263\200\354\247\200\355\230\221/v3/1837. Sum of Digits in Base K.py" new file mode 100644 index 00000000..cd7f42f7 --- /dev/null +++ "b/leetcode3/\353\263\200\354\247\200\355\230\221/v3/1837. Sum of Digits in Base K.py" @@ -0,0 +1,24 @@ + +''' +1. 아이디어 : +k진수로 변환하고, 각 자리수를 더한다. + +2. 시간복잡도 : +o(log n) + +3. 자료구조/알고리즘 : +''' +class Solution: + def sumBase(self, n: int, k: int) -> int: + s = '' + while True: + if n == 0: + break + r = n % k + n = n // k + s += str(r) + + print(s) + + return sum([int(i) for i in s]) + \ No newline at end of file