BigInteger.GreatestCommonDivisor Method

Finds the greatest common divisor of two BigInteger values.

Namespace:  System.Numerics
Assembly:  System.Numerics (in System.Numerics.dll)

static member GreatestCommonDivisor : 
        left:BigInteger * 
        right:BigInteger -> BigInteger 

Parameters

left
Type: System.Numerics.BigInteger
The first value.
right
Type: System.Numerics.BigInteger
The second value.

Return Value

Type: System.Numerics.BigInteger
The greatest common divisor of left and right.

The greatest common divisor is the largest number into which the two BigInteger values can be divided without returning a remainder.

If the left and right parameters are non-zero numbers, the method always returns at least a value of 1 because all numbers can be divided by 1. If either parameter is zero, the method returns the absolute value of the non-zero parameter. If both values are zero, the method returns zero.

NoteNote

Computing the greatest common divisor of very large values of left and right can be a very time-consuming operation.

The value returned by the GreatestCommonDivisor method is always positive regardless of the sign of the left and right parameters.

The following example illustrates a call to the GreatestCommonDivisor method and the exception handling necessary to provide useful information about an ArgumentOutOfRangeException. The result indicates that the greatest common divisor of these two numbers is 1.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft