Didn't understand the Solution

I don’t understand the solution to this problem.
why are we looking for prime factors and what is the proof that this solution of considering prime factors as pile will work?

@priyanshnigam972 hey , This is a traditional example of game theory .
So , basically for every n you have to insert grundy of every divisors of n including 1 but not n itself in a set .And then return Max of the elements of set .