pow()
Raise a number to a power.
Syntax
pow(base,exponent)
Parameter
Parameter | Definition |
---|---|
base | numeric value that is to be multiplied by itself exponent number of times |
exponent | numeric value that indicates the number of times base should be multiplied by itself The exponent must be positive if base = 0, and exponent must be an integer if base < 0 |
Description
The pow() function returns the value of base raised to the power exponent, or baseexponent.
The output range for the pow() function is – ∞ < pow() < ∞ .
Example
The following PSL script uses the pow() function to produce a table of powers of the integers from one to nine.
function main() {
print(" n n^4 n^5 n^6 n^7 n^8 n^9\n");
print("-- --------- --------- --------- --------- --------- ---------\n");
base = 1;
while (base <= 9) {
printf("%2d",base);
exponent = 4;
while (exponent <= 9) {
printf(" %9d",pow(base,exponent));
exponent++;
}
printf("\n");
base++;
}
}
print(" n n^4 n^5 n^6 n^7 n^8 n^9\n");
print("-- --------- --------- --------- --------- --------- ---------\n");
base = 1;
while (base <= 9) {
printf("%2d",base);
exponent = 4;
while (exponent <= 9) {
printf(" %9d",pow(base,exponent));
exponent++;
}
printf("\n");
base++;
}
}
The example produces the following table:
n n^4 n^5 n^6 n^7 n^8 n^9
-- --------- --------- --------- --------- --------- ---------
111111 1
2163264128256 512
38124372921876561 19683
4 256 1024 4096 16384 65536 262144
5 625 3125 15625 78125 390625 1953125
6 1296 7776 46656 279936 1679616 10077696
72401 16807 117649 823543 5764801 40353607
8 4096 32768 262144 2097152 16777216 134217728
9 6561 59049 531441 4782969 43046721 387420489
-- --------- --------- --------- --------- --------- ---------
111111 1
2163264128256 512
38124372921876561 19683
4 256 1024 4096 16384 65536 262144
5 625 3125 15625 78125 390625 1953125
6 1296 7776 46656 279936 1679616 10077696
72401 16807 117649 823543 5764801 40353607
8 4096 32768 262144 2097152 16777216 134217728
9 6561 59049 531441 4782969 43046721 387420489
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*