Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

recursive --> iteration

Name: Anonymous 2012-01-31 21:11

hello /prog/, yes this is basically homework help...

I have a C function that computes the eth power of a number x, modulo another number m, where e is very large. The function uses recursion to do so. I need to implement the program using iteration. I've attempted it and i'm really stuck here, i provided both functions in this paste: http://pastebin.com/ayb87BBr

can someone please point out my stupid mistakes?

Name: Anonymous 2012-02-01 8:44

long int powermod(int x, int e, int m){
int _x = x;
--e;
while(--e)
x *= _x;
return x % m;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List