i have some knowldege of fermats little theorem but for that i think 'b' must be of the form : b=k*(p1) + m...and the answer would be a^m...but in my case 'b' is smaller than p for example b is 10^7(so i cant express 'b' in terms of 'p') ...?? By simply writing the expression it is overflowing the long long int range ..plz help asked 12 May '15, 11:28

you can use repeated squaring it basically depends on the fact you can use code:
you can get more information from wikiExponentiation by squaring answered 12 May '15, 12:47

answered 12 May '15, 15:42

answered 12 May '15, 15:45
