Exercise · Operators and Expressions · lesson 7 of 8
Exercise: digit sum of a three-digit number
Write a function int digit_sum(int n) that returns the sum of the digits of the three-digit number n.
digit_sum(123)→6digit_sum(507)→12digit_sum(100)→1
Constraints: n is an integer from 100 to 999 inclusive.