c - Function's return value is unexpected -


long long encrypt(int message,int n,int e) { long long s=pow(message,e); return s%n; } 

when try this:

        printf("%lli",encrypt(65,3233,17)); 

it prints out this: -2631

does have idea how fix this...to honest small values now..i think i'll use larger values in future

perhaps do:

int encrypt(int message,int n,int e) {     int s = 1;     while (e--) {         s = ( s * message ) % n;     }     return s; } 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -