Sum Even Minus Odd Digits
EasyMath
Description
Given an integer n, compute the sum of its even digits minus the sum of its odd digits (using the absolute value of n).
Examples
Input:
n = 1234Output:
2Explanation:
Even 2+4=6, odd 1+3=4, diff=2.
Input:
n = 9Output:
-9Explanation:
Only odd digit 9.
Input:
n = 2468Output:
20Explanation:
All digits even, sum=20.
Constraints
- •
-10¹⁸ ≤ n ≤ 10¹⁸