Prime Game

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    int n, xor_sum = 0, c = 0;

    cout << "Enter Any Number : ";
    cin >> n;

    while(n%2 == 0)
    {
        c++;
        n /= 2;
    }
    xor_sum ^= c;

    for(int i=3; i*i<=n; i+=2)
    {
        c = 0;
        while(n%i == 0)
        {
           c++;
           n /= i;
        }

        xor_sum ^= c;
    }

    if(xor_sum > 0)
        cout << "First Player Win." << "\n";
    else
        cout << "Second Player Win." << "\n";

    return 0;
}

Comments