#3099

Harshad Number

easy · 83.4% accepted · 212 likes · top 95%

math

Description

An integer divisible by the sum of its digits is said to be a Harshad number. You are given an integer x. Return the sum of the digits of x if x is a Harshad number, otherwise, return -1.

Solution