C# BigInteger GreatestCommonDivisor

Description

BigInteger GreatestCommonDivisor Finds the greatest common divisor of two BigInteger values.

Syntax

BigInteger.GreatestCommonDivisor has the following syntax.


public static BigInteger GreatestCommonDivisor(
  BigInteger left,
  BigInteger right
)

Parameters

BigInteger.GreatestCommonDivisor has the following parameters.

  • left - The first value.
  • right - The second value.

Returns

BigInteger.GreatestCommonDivisor method returns The greatest common divisor of left and right.

Example


using System;/* ww  w . j a  va2s  . c  o  m*/
using System.IO;
using System.Numerics;

public class Example
{
   public static void Main()
   {
        BigInteger n1 = BigInteger.Pow(154382190, 3);
        BigInteger n2 = BigInteger.Multiply(1643590, 166935);
        Console.WriteLine(BigInteger.GreatestCommonDivisor(n1, n2));
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Numerics »




BigInteger
Complex