Description

Given a non-negative integer n, return the sum of the squares of its decimal digits. For example, the digit-square-sum of 19 is 1² + 9² = 82.

Examples

Input:n = 19
Output:82
Explanation:

Digits are 1 and 9. 1² + 9² = 1 + 81 = 82.

Input:n = 7
Output:49
Explanation:

Single digit 7; 7² = 49.

Input:n = 100
Output:1
Explanation:

Digits are 1, 0, 0. 1² + 0² + 0² = 1.

Input:n = 0
Output:0
Explanation:

Single digit 0; result = 0.

Constraints

  • 0 ≤ n ≤ 2³¹ - 1

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!