Skip to content

Practice Sum of Digits in Base K

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1837
LeetCode Problem

Sum of Digits in Base K

Problem Statement

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. After converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10.

Source: Sum of Digits in Base K on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 34, k = 6
Output
9

# Example 2

Input
n = 10, k = 10
Output
1

Constraints

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

Related LeetCode Problems

Practice more problems similar to Sum of Digits in Base K.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.