Project Euler 334(2)

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

できた。0.01s。ものすごくつまらないミスだった。
フォーラムで同じ考え方をしている人がいた。