The `pow` method calculates the power of a big integer to a specified exponent.
The syntax of BigInt.pow() method is:
BigInt pow(int exponent)
This pow() method of BigInt returns this
to the power of exponent
.
Parameter | Optional/Required | Description |
---|---|---|
exponent | required | the exponent to which to raise the big integer |
BigInt.pow() returns value of type BigInt
.
In this example,
num
, initialized with 225632.pow
method to calculate 225632 raised to the power of 5.void main() {
BigInt num = BigInt.from(225632);
BigInt result = num.pow(5);
print('$num raised to the power of 5: $result');
}
225632 raised to the power of 5: 584794749865291602232082432
In this example,
num
, initialized with 10.pow
method to calculate 10 raised to the power of 2.void main() {
BigInt num = BigInt.from(10);
BigInt result = num.pow(2);
print('10 raised to the power of 2: $result');
}
10 raised to the power of 2: 100
In this example,
num
, initialized with 5.pow
method to calculate 5 raised to the power of 4.void main() {
BigInt num = BigInt.from(5);
BigInt result = num.pow(4);
print('5 raised to the power of 4: $result');
}
5 raised to the power of 4: 625
In this Dart tutorial, we learned about pow() method of BigInt: the syntax and few working examples with output and detailed explanation for each example.