LeetCode 1837. Sum of Digits in Base K Posted on 2021-04-26 Edited on 2024-11-24 In LeetCode 1234567891011class Solution {public: int sumBase(int n, int k) { int ans = 0; while (n) { ans += n % k; n /= k; } return ans; }};