Skip to content

Instantly share code, notes, and snippets.

@qnighy
Created March 31, 2009 13:00
Show Gist options
  • Save qnighy/88175 to your computer and use it in GitHub Desktop.
Save qnighy/88175 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
template <int a, int b>
struct gcm
{
static const int value = gcm<b, a%b>::value;
};
template <int a>
struct gcm<a, 0>
{
static const int value = a;
};
template<int a, int b>
struct lcm
{
static const int value = a * b / gcm<a, b>::value;
};
int main(int argc, char *argv[], char *envp[])
{
cout << lcm<128, 72>::value << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment