// An Armstrong number of three digits is an integer that the sum
// of the cubes of its digits is equal to the number itself
// 371 is an Armstrong number: 3**3 + 7**3 + 1**3 = 371
package main
import (
"fmt"
)
func IsArmstrongNumber(n int) bool {
reminder, sum := 0, 0
tmp := n
for n != 0 {
reminder = n % 10
n = n / 10
sum += reminder * reminder * reminder
}
return sum == tmp
}
func main() {
n := 371
if IsArmstrongNumber(n) {
fmt.Printf("%d is an Armstrong number\n", n)
} else {
fmt.Printf("%d is not an Armstrong number\n", n)
}
}
/*
run:
371 is an Armstrong number
*/