x. Add up its digits.
If x is evenly divisible by that sum, return the sum. Otherwise return -1.x=27 → 9
The digits add up to 2 + 7 = 9, and 27 is divisible by 9, so the answer is 9.
x=35 → -1
The digit sum is 8, and 35 is not divisible by 8, so the answer is -1.
x=100 → 1
x ≤ 10⁹x=27
9
Run checks the first 3 tests in your browser. Submit checks all 56 tests on the server, hidden ones included.