A positive integer is called an Armstrong number if the sum of cubes of each digits is equal to the number itself.
For example,
153 = 1*1*1 + 5*5*5 + 3*3*3 // 153 is an Armstrong number.
package main/*w ww. j av a2s . c o m*/ import "fmt" func main() { var number,tempNumber,remainder int var result int =0 number = 153 tempNumber = number for { remainder = tempNumber%10 result += remainder*remainder*remainder tempNumber /=10 if(tempNumber==0){ break // Break Statement used to stop the loop } } if(result==number){ fmt.Printf("%d is an Armstrong number.",number) }else{ fmt.Printf("%d is not an Armstrong number.",number) } }