BigInteger.Pow Method (System.Numerics)

Switch View :
ScriptFree
.NET Framework Class Library
BigInteger.Pow Method

Raises a BigInteger value to the power of a specified value.

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

Visual Basic
Public Shared Function Pow ( _
	value As BigInteger, _
	exponent As Integer _
) As BigInteger
C#
public static BigInteger Pow(
	BigInteger value,
	int exponent
)
Visual C++
public:
static BigInteger Pow(
	BigInteger value, 
	int exponent
)
F#
static member Pow : 
        value:BigInteger * 
        exponent:int -> BigInteger 

Parameters

value
Type: System.Numerics.BigInteger
The number to raise to the exponent power.
exponent
Type: System.Int32
The exponent to raise value by.

Return Value

Type: System.Numerics.BigInteger
The result of raising value to the exponent power.
Exceptions

Exception Condition
ArgumentOutOfRangeException

The value of the exponent parameter is negative.

Remarks

The Pow method returns 1 if the value of the exponent parameter is 0, or if the values of both the value and exponent parameters are 0. If exponent is 1, the Pow method returns value. If value is negative, the method returns a negative result.

This method corresponds to the Math.Pow method for primitive numeric types.

Examples

The following example illustrates exponentiation using a BigInteger value and an exponent whose value ranges from 0 to 10.

Visual Basic

Dim base As BigInteger = 3040506
For ctr As Integer = 0 To 10
   Console.WriteLine(BigInteger.Pow(base, ctr))
Next
' 
' The example produces the following output to the console:
'
' 1
' 3040506
' 9244676736036
' 28108495083977874216
' 85464047953805230420993296
' 259853950587832525926412642447776
' 790087495886008322074413197838317614656
' 2402265771766383619317185774506591737267255936
' 7304103492650319992835619250501939216711515276943616
' 22208170494024253840136657344866649200046662468638726109696
' 67524075636103707946458547477011116092637077515870858568887346176     '


C#

BigInteger numericBase = 3040506;
for (int ctr = 0; ctr <= 10; ctr++)
{
   Console.WriteLine(BigInteger.Pow(numericBase, ctr));
}
// 
// The example produces the following output to the console:
//
// 1
// 3040506
// 9244676736036
// 28108495083977874216
// 85464047953805230420993296
// 259853950587832525926412642447776
// 790087495886008322074413197838317614656
// 2402265771766383619317185774506591737267255936
// 7304103492650319992835619250501939216711515276943616
// 22208170494024253840136657344866649200046662468638726109696
// 67524075636103707946458547477011116092637077515870858568887346176     //


Version Information

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4
Platforms

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.
See Also

Reference