Created
March 31, 2009 13:00
-
-
Save qnighy/88175 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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