Created
January 30, 2018 02:30
-
-
Save junichiro/95654bfcaa8050f11dff0990545af87e to your computer and use it in GitHub Desktop.
会社で少し盛り上がった Project Euler をやってみる 007 ref: https://qiita.com/junichiro/items/ca842ce0402c2d77463f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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