unsigned long long rpow(int n, int p) {
return p ? p==1 ? n : n * rpow(n,p-1) : 1;
}
int main(int argc, char **argv) {
if(argv[1])
if(argv[2]) {
int n = atoi(argv[1]);
int p = atoi(argv[2]);
printf("%llu\n",rpow(n,p));
}
return 0;
}
Name:
Anonymous2009-03-13 1:07
>>142
Fortunately for the planned implementation that uses a LOOKUP TABLE. It will be able to directly access the area of memory it requires. Taking infact, a single clock cycle to complete (well, probably a few more if done a more intuitive way of double indexing where a multiplication and addition would be required in addition to acessing the memory). And if this wasn't the case and it did take ten seconds; it would be infinitely times more useful than a regular power function. PROTIP: Peicewise functions.