Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int pow(int b, int p) {
- if (p == 1) {
- return 2;
- }
- int result = 1;
- if (p % 2 == 0) {
- p /= 2;
- result = pow(b, p);
- result *= result;
- } else {
- result = pow(b, p - 1);
- result *= b;
- }
- return result;
- }
- int main() {
- int n = 2, k = 30;
- printf("%d\n", pow(n, k));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement