Skip to content

Instantly share code, notes, and snippets.

@ik11235
Created March 9, 2015 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ik11235/ced670ef8c84f07a96e5 to your computer and use it in GitHub Desktop.
Save ik11235/ced670ef8c84f07a96e5 to your computer and use it in GitHub Desktop.
class ThePermutationGameDiv2 {
public:
long long int lcm(long long int a,long long int b)
{
if (b==0 || a == 0 )
return 0;
return ((a / gcd(a, b)) * b);
}
long long int gcd(long long int a,long long int b)
{
return b==0?a:gcd(b, a%b);
}
long long findMin(int N) {
long long ans=1;
for(int i=2;i<=N;i++)
{
ans=lcm(ans,i);
}
return ans;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment