Sum of Digits
Sum of Digits
EasyLoops39% accepted
Given a positive integer, compute the sum of its individual digits. For example, 1234 has digits 1, 2, 3, 4 and their sum is 10. This teaches you how to extract digits one by one using the modulo operation.
Approach
Given a positive integer N, print the sum of its digits.
Input
0
Output
0
More Loops problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards