Problem:
Score : 200 points

Problem Statement

Takahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:

Go one meter in the direction he is facing. Then, turn X degrees counter-clockwise.

Constraints

1 \leq X \leq 179

X is an integer.

Input

Input is given from Standard Input in the following format:

X

Output

Print the number of times Takahashi will do the action before he is at the starting position again.

Sample Input 1

90

Sample Output 1

4

Takahashi's path is a square.

Sample Input 2

1

Sample Output 2

360

Solution in Go (1.14.1) (judge verdict: Wrong Answer)

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scan_init()
	X := scanInt()
		pailist := primeFactorizate(360)
		targetlist := primeFactorizate(X)
		// fmt.Println(pailist,targetlist)
		count := 1
		fmt.Println(pailist,targetlist)
		for key,val := range pailist {
			if _,ok := targetlist[key]; ok {
				// fmt.Println(key,val, "ari",tar)
				count *= pow(key,val-targetlist[key],key)
			} else {
				// fmt.Println(key,val, "nasi")
				count *= pow(key,val,key)
			}
		}
	fmt.Println(count)
}
func pow(n int, number int,sum int) int {
	if number <= 0 {
		return 1
	}
	if number > 1 {
		return pow(n, number-1, sum*n)
	} else {
		return sum
	}
}
var sc = bufio.NewScanner(os.Stdin)
func scan_init () {
	sc.Split(bufio.ScanWords)
}
func scanInt () int{
sc.Scan()
	i,_ := strconv.Atoi(sc.Text())
	return i
}
//func scan () string{
//  sc.Scan()
//	return sc.Text()
//}
func primeFactorizate (number int ) map[int]int{
	var N int
	N = number
	var memo map[int]int
	memo = map[int]int{}
	// fmt.Println(N)
	for i:=2; i * i <= N; i++ {
		if N % i == 0{
			target := i
			check := true
			for check {
				check = false
				for j, value := range memo {
					if target%j == 0 {
						target = target / j
						memo [j] = value + 1
						check = true
						break
					}
				}
			}
			if target != 1 {
				// fmt.Println(target)
				memo[target] = 1
			}
			N = N/i
		}
	}
	target := N
	check := true
	for check {
		check = false
		// fmt.Println(memo,target)
		for j, value := range memo {
			// fmt.Println(j,value,target)
			if target%j == 0 {
				target = target / j
				memo [j] = value + 1
				check = true
				break
			}
		}
	}
	if target != 1 {
		// fmt.Println("check",target)
		memo[target] = 1
	}
	return memo
}