get Greatest Common Divisor - CSharp System

CSharp examples for System:Math Geometry

Description

get Greatest Common Divisor

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//  w w w.ja  va 2s .c  o  m

public class Main{

        public static int getGreatestCommonDivisor(int numberA,int numberB)
        {
            int result = 1;
            if (numberA > numberB)
                result = gcd(numberA, numberB);
            else {
                result = gcd(numberB, numberA);
            }
            return result;
        }
}

Related Tutorials