Though seems like it can’t be solved without using bignumber(in c/c++), The bignumber solution takes much more time than we can say moderate for a computer program(same in JAVA). Actually it needs some modular operations. You need the last ten digits and to calculate them you don’t need to calculate all the digits. See my approach