- using System;
- using System.Text;
- namespace forgetCode
- {
- class program
- {
- public static void Main()
- {
- long x, y, hcf, lcm;
- Console.WriteLine("Enter two integers");
- x = Convert.ToInt64(Console.ReadLine());
- y = Convert.ToInt64(Console.ReadLine());
- hcf = gcd(x, y);
- lcm = (x * y) / hcf;
- Console.WriteLine("Greatest common divisor of {0} and {1} = {2}\n", x, y, hcf);
- Console.WriteLine("Least common multiple of {0} and {1} = {2}\n", x, y, lcm);
- }
- static long gcd(long a, long b)
- {
- if (b == 0)
- {
- return a;
- }
- else
- {
- return gcd(b, a % b);
- }
- }
- }
- }