using System; |
namespace ConsoleApplication4 |
{ |
class Program |
{ |
public static int lcm( int a, int b) |
{ |
int r = 0; |
for (r = a; r < a * b; r += a) |
{ |
if (r % b == 0) |
break ; |
} |
return r; |
} |
public static int gcd( int a, int b) |
{ |
int r = a % b; |
while (r != 0) |
{ |
a = b; |
b = r; |
r = a % b; |
} |
return b; |
} |
static void Main( string [] args) |
{ |
Console.WriteLine( "2,10的最小公倍数:" + lcm(2, 10)); |
Console.WriteLine( "2,10的最大公约数:" + gcd(2, 10)); |
Console.ReadKey(); |
} |
} |
} |