{ long x,y;
if (i == 0) return 1;
x = power(a, i/2, n);
y = ( x * x ) % n ;
if ( i % 2 != 0 ) y= ( a * y ) % n;
return y; }