mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Explicitly cast result of Math.pow to long in Armstrong (#4972)
This commit is contained in:
@@ -27,7 +27,7 @@ public class Armstrong {
|
||||
|
||||
while (originalNumber > 0) {
|
||||
long digit = originalNumber % 10;
|
||||
sum += Math.pow(digit, power); // The digit raised to the power of the number of digits and added to the sum.
|
||||
sum += (long) Math.pow(digit, power); // The digit raised to the power of the number of digits and added to the sum.
|
||||
originalNumber /= 10;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user