Skip to content

Commit 9bebcee

Browse files
authored
Make sumOfDigits long in HarshadNumber.isHarshad (#4973)
fix: make `sumOfDigits` `long` in `HarshadNumber.isHarshad`
1 parent fc21a8b commit 9bebcee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/com/thealgorithms/maths/HarshadNumber.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static boolean isHarshad(long n) {
1515
if (n <= 0) return false;
1616

1717
long t = n;
18-
int sumOfDigits = 0;
18+
long sumOfDigits = 0;
1919
while (t > 0) {
2020
sumOfDigits += t % 10;
2121
t /= 10;

0 commit comments

Comments
 (0)