function compound interest and modular arithmetic