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
Post a Comment