Compute the Checksum Seed

Basic

A simple checksum routine starts by summing the decimal digits of an account number. Build that digit-sum step.

Implement `solve(Integer n)` (non-negative) to return the sum of its decimal digits.

Examples

Inputn = 1234
Output10
Inputn = 0
Output0
Hints
  • Repeatedly take Math.mod(n, 10) and divide n by 10.
Anonymous Apex

Your code runs in a secure sandbox against multiple hidden test cases. The problem is solved only when every test passes. Each run is isolated and any data changes are rolled back automatically.