Created
December 17, 2013 22:43
-
-
Save i/8014008 to your computer and use it in GitHub Desktop.
Sexy way to calculate numbers raised to some exponent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int total; | |
void npowerk(int n, int k) { | |
int i; | |
if (k > 0) | |
for (i = 0; i < n; i++) | |
npowerk(n, k - 1); | |
else | |
total ++; | |
} | |
int main(int argc, char **argv) { | |
total = 0; | |
npowerk(atoi(argv[1]), atoi(argv[2])); | |
printf("%d\n", total); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment