Using totient fn. for n<10^4 to answer given code