Skip to content

Instantly share code, notes, and snippets.

@abdalimran
Created February 12, 2016 19:04
Show Gist options
  • Save abdalimran/5d3b2a4fb917e5518131 to your computer and use it in GitHub Desktop.
Save abdalimran/5d3b2a4fb917e5518131 to your computer and use it in GitHub Desktop.
/* Bismillah hir rahmanir raheem. Thanks to Allah for everything.
Coder: Abdullah Al Imran
Email: [email protected] */
#include<bits/stdc++.h>
using namespace std;
//Recursively
int gcd(int a, int b)
{
if(b==0)
return a;
else
return gcd(b, a%b);
}
//Shortly
int gcd(int a, int b)
{
return b == 0?a:gcd(b,a%b);
}
int main()
{
ios_base::sync_with_stdio(false);
//cout<<gcd(8,10)<<endl;
cout<< __gcd(8,12)<<endl; //This function works only in gnu gcc/g++ compilers.
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment