Skip to content

Instantly share code, notes, and snippets.

@junichiro
Created January 30, 2018 02:30
Show Gist options
  • Save junichiro/95654bfcaa8050f11dff0990545af87e to your computer and use it in GitHub Desktop.
Save junichiro/95654bfcaa8050f11dff0990545af87e to your computer and use it in GitHub Desktop.
会社で少し盛り上がった Project Euler をやってみる 007 ref: https://qiita.com/junichiro/items/ca842ce0402c2d77463f
class Problem7:
LIMIT = 10001
PRIME = []
def main(self):
i = 1
while(len(self.PRIME) < self.LIMIT):
i = i + 1
if self.isPrime(i):
self.PRIME.append(i)
print(self.PRIME[-1])
def isPrime(self, num):
for i in self.PRIME:
if num % i == 0:
return False
if i * i > num:
break
return True
if __name__ == '__main__':
p = Problem7()
p.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment