محاسبه ی ک.م.م و ب.م.م
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _17___KMM_BMM
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine (" Please enter 2 numbers : ");
int x = Convert.ToInt32 (Console.ReadLine ());
int y = Convert.ToInt32 (Console.ReadLine ());
Console.WriteLine ("GCD (x,y) = {0} ", MyMath.Gcd(x,y));
Console.WriteLine("LCM (x,y) = {0} ", MyMath.Lcm(x, y));
Console.ReadKey();
}
}
class MyMath
{
public static int Gcd (int x,int y)
{
int remainer;
while (y != 0)
{
remainer = x % y;
x = y;
y = remainer;
}
return x;
}
public static int Lcm(int x, int y)
{
return (x * y) / Gcd(x, y);
//shmp30
}
}
}
علاقه مندی ها (بوک مارک ها)