TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Compute powers of large numbers. More...
#include <iostream>
Go to the source code of this file.
Macros | |
#define | MAX 100000 |
Functions | |
int | multiply (int x, int res[], int res_size) |
void | power (int x, int n) |
int | main () |
Compute powers of large numbers.
Definition in file power_for_huge_numbers.cpp.
#define MAX 100000 |
Maximum number of digits in output \(x^n\) where \(1 <= x,\; n <= 10000\) and overflow may happen
Definition at line 10 of file power_for_huge_numbers.cpp.
int main | ( | void | ) |
Main function
Definition at line 82 of file power_for_huge_numbers.cpp.
int multiply | ( | int | x, |
int | res[], | ||
int | res_size ) |
This function multiplies x with the number represented by res[]. res_size is size of res[] or number of digits in the number represented by res[]. This function uses simple school mathematics for multiplication. This function may value of res_size and returns the new value of res_size
x | multiplicand |
res | large number representation using array |
res_size | number of digits in res |
Definition at line 25 of file power_for_huge_numbers.cpp.
void power | ( | int | x, |
int | n ) |
This function finds power of a number x and print \(x^n\)
x | base |
n | exponent |
Definition at line 56 of file power_for_huge_numbers.cpp.