golang水仙花数
package main import ( "fmt" ) var ( j int k int p int ) func main() { for i := 100; i <= 999; i++ { j = i / 100 //百位 k = i / 10 % 10 //十位 p = i % 10 //个位 if j*j*j+k*k*k+p*p*p == i { fmt.Println(i) } } }
Welcome to visit
package main import ( "fmt" ) var ( j int k int p int ) func main() { for i := 100; i <= 999; i++ { j = i / 100 //百位 k = i / 10 % 10 //十位 p = i % 10 //个位 if j*j*j+k*k*k+p*p*p == i { fmt.Println(i) } } }