Package algorithm; public class algorithm_modtest {public static void main (string [] ARGs) {modprocess MP = new modprocess (2,100, 5); MP. findmodprocess (); MP. getresult () ;}} class modprocess {int basenumber; int exponent; int modnumber; int minexponent; int modresult; modprocess (int B, int e, int m) {This. basenumber = B; this. exponent = E; this. modnumber = m; this. minexponent = 1; this. modresult = 0;} public void findmodprocess () {If (this. exponent <this. modnumber) {This. modresult = getexponentvalue (this. basenumber, this. exponent) % This. modnumber;} else {This. minexponent = findminexponent (); // find the smallest index int remainexponent = This. exponent; while (remainexponent> = This. minexponent) {remainexponent = remainexponent-this. minexponent;} int remainnumber = getexponentvalue (this. basenumber, remainexponent); this. modresult = remainnumber % This. modnumber ;}} public int findminexponent () // find the smallest index {Boolean B = true; int sum = This. basenumber; int mincount = 1; while (B) {If (Sum-1) % (this. modnumber) = 0) {B = false;} else {sum = sum * This. basenumber; mincount ++;} return mincount;} public void getresult () // result processing {system. out. println ("modresult:" + this. modresult);} public int getexponentvalue (INT base, int e) // obtain the integer index value {int result = 1; for (INT I = 0; I <E; I ++) {result = Result * base;} return result ;}}