package main import ( "bufio" "fmt" "os" "strconv" "strings" ) type PerfectNumber struct { number int stadardValue int sum int } func (p PerfectNumber) Result() string { if p.sum == p.number*2 { return "OK" } return "NG" } func main() { var scan *bufio.Scanner scan = bufio.NewScanner(os.Stdin) scan.Scan() stringInput := scan.Text() number, err := strconv.Atoi(strings.TrimSpace(stringInput)) if err != nil { panic(err) } perfectNumber := PerfectNumber{number: number, stadardValue: number} for i := 1; i <= number; i++ { if number%i == 0 { if i < perfectNumber.stadardValue { result := number / i perfectNumber.sum += i perfectNumber.sum += result perfectNumber.stadardValue = result } else { break } } } fmt.Print(perfectNumber.Result()) }