Project Euler 512 - Sums of totients of powers

Official link: https://projecteuler.net/problem=512

Note: My code takes around ~1000s, ~24s with pypy