Created
August 4, 2011 05:56
-
-
Save shwangdev/1124581 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<stdio.h> | |
int gcd( long long int m , long long int n ) | |
{ | |
int t; | |
if ( m < n ) | |
{ | |
t = m; | |
m = n ; | |
n = t; | |
} | |
if ( n == 0 ) | |
return m; | |
return gcd( n , m % n) ; | |
} | |
int lcm( long long int m , long long int n ) | |
{ | |
return m * n / gcd( m, n ); | |
} | |
int main(int argc, char * argv[]) | |
{ | |
int n= 20 ; | |
long long data[100]; | |
long long g,l; | |
for( int i = 0 ; i < n ; ++i ) | |
{ | |
data[i] = i+1; | |
} | |
g = data[0]; | |
for( int i = 1; i < n ; i++ ) | |
{ | |
g = lcm( g, data[i]); | |
} | |
printf ( "%ld\n", g); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment