Project Euler 313

http://projecteuler.net/index.php?section=problems&id=313


やっと出来た。2秒。なんだろうね、簡単な問題のはずなのに。