mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-09 03:59:38 +08:00
Make sumOfDigits
long
in HarshadNumber.isHarshad
(#4973)
fix: make `sumOfDigits` `long` in `HarshadNumber.isHarshad`
This commit is contained in:
@ -15,7 +15,7 @@ public class HarshadNumber {
|
||||
if (n <= 0) return false;
|
||||
|
||||
long t = n;
|
||||
int sumOfDigits = 0;
|
||||
long sumOfDigits = 0;
|
||||
while (t > 0) {
|
||||
sumOfDigits += t % 10;
|
||||
t /= 10;
|
||||
|
Reference in New Issue
Block a user