Sum of Digits in Base K Problem

Sum of Digits in Base K Problem — ExecCode Easy DSA Practice

Solve the Sum of Digits in Base K problem on ExecCode. Free online easy DSA practice in Math. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k. Your task is to after converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10. Return the required answer exactly as shown in the examples.

Examples

Input {"n": 34, "k": 6}; Output 9. Input {"n": 10, "k": 10}; Output 1

Constraints

1 <= n <= 100 2 <= k <= 10

Practice Sum of Digits in Base K free on ExecCode. Browse DSA problems, topic map, and placement guides.