Sum of Digits — C# Coding Problem
Difficulty: easy | Category: math
Problem Description
Given a non-negative integer `n`, return the sum of its digits. For example, `sum_of_digits(123)` returns `6` (1 + 2 + 3).
Examples
Example 1
Input: n = 123
Output: 6
Example 2
Input: n = 9999
Output: 36
Example 3
Input: n = 0
Output: 0