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 - Unusual behaviour when drawing lots of images onto a large canvas -

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

javascript - Chart.js - setting tooltip z-index -