(number int)
| 14 | ) |
| 15 | |
| 16 | func IsArmstrong(number int) bool { |
| 17 | var rightMost int |
| 18 | var sum int = 0 |
| 19 | var tempNum int = number |
| 20 | |
| 21 | // to get the number of digits in the number |
| 22 | length := float64(len(strconv.Itoa(number))) |
| 23 | |
| 24 | // get the right most digit and break the loop once all digits are iterated |
| 25 | for tempNum > 0 { |
| 26 | rightMost = tempNum % 10 |
| 27 | sum += int(math.Pow(float64(rightMost), length)) |
| 28 | |
| 29 | // update the input digit minus the processed rightMost |
| 30 | tempNum /= 10 |
| 31 | } |
| 32 | |
| 33 | return number == sum |
| 34 | } |
no outgoing calls