Project Euler 725

https://projecteuler.net/problem=725

259着。

問題は S(2020)を求めよでしたが、 S(10^6)がPyPyで10秒以内でした。