← Home
For problem statement at 0-999/200-299/280-289/284/problemA.txt this is a correct solution, but verifier at 0-999/200-299/280-289/284/verifierA.go ends with All tests passed can you fix the verifier? package main

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

func phi(n int) int {
	if n == 1 {
		return 1
	}
	res := n
	x := n
	for p := 2; p*p <= x; p++ {
		if x%p == 0 {
			for x%p == 0 {
				x /= p
			}
			res = res / p * (p - 1)
		}
	}
	if x > 1 {
		res = res / x * (x - 1)
	}
	return res
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var p int
	fmt.Fscan(in, &p)
	fmt.Println(phi(p - 1))
}