Question not clear

when does a player win i.e. what is the winning criteria.

@ParvBudh First calculate total powers of all prime number in array. For example - in array {1, 2, 4, 6} total powers of 2 will be 4. Now let me try to relate this problem with a classical game theory problem.

Let prime numbers are piles of stones and their total prime powers in array are equivalent to respective piles size. Now this has become a problem where two players are playing optimally and they reduce every pile to size 0. The last player unable to move loses.

Read over internet about NIM game and let me know where you are stuck.