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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -