package main
import (
"fmt"
)
func div(x int) bool {
var b int
a := []int{}
for i := 1; ix/2; i++ {
if x%i == 0 {
a = append(a, i)
}
}
for _, num := range a {
b += num
}
if b == x {
return true
} else {
return false
}
}
func main() {
for i := 2; i 1000; i++ {
if ok := div(i); ok {
fmt.Printf("%d ", i)
}
}
}
运行结果:
6 28 496