go求abc=a^3+b^3+c^3

package main

import "fmt"

func isOk(n int) bool {
	tmp := n
	a := tmp % 10
	tmp /= 10
	b := tmp % 10
	tmp /= 10
	c := tmp
	if a * a * a + b * b * b + c * c * c == n {
		return true
	}
	return false
}

func main() {
	for val := 100; val <= 999; val++ {
		if isOk(val) {
			fmt.Println(val)
		}
	}
}
posted @ 2022-02-26 22:55  ty1539  阅读(105)  评论(0编辑  收藏  举报