Sunday, 1 September 2013

hcf and lcm of two number?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace lcm
{
    class Program
    {
       static void Main(string[] args)
       {
           int num,num1,number,number1,rem=0,lcm1,hcf=0;
           num = Int32.Parse(Console.ReadLine());
           num1 = Int32.Parse(Console.ReadLine());
           number = num;
           number1 = num1;
           rem = num % num1;
           while (rem !=0)
           {
               rem = num % num1;
               num = num1;
               num1 = rem;
              
           }
           

           Console.WriteLine("hcf os number is " + num);
           lcm1 = (number * number1 )/ num;
           Console.WriteLine("lcm os number is " + lcm1);

       }
    }
}

No comments:

Post a Comment