From fc957936ceb2e122ec7084c1e2c6062625823cfa Mon Sep 17 00:00:00 2001 From: Apoorv Singh <40769379+Appy1412@users.noreply.github.com> Date: Mon, 29 Oct 2018 18:10:53 +0530 Subject: [PATCH] Add files via upload --- Sieve_ of_Eratosthenes.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Sieve_ of_Eratosthenes.py diff --git a/Sieve_ of_Eratosthenes.py b/Sieve_ of_Eratosthenes.py new file mode 100644 index 0000000..71f3768 --- /dev/null +++ b/Sieve_ of_Eratosthenes.py @@ -0,0 +1,20 @@ +import sys +sys.stdin = open('input.txt', 'r') +sys.stdout = open('output.txt', 'w') + +M = int(1e6) + 1 + +composite = [0 for i in xrange(int(M))] + +def sieve(): + for i in xrange(2, M): + cnt = 2 + while cnt*i < M: + composite[cnt*i] = 1 + cnt += 1 + +if __name__ == '__main__': + print composite[2] + print composite[5] + print composite[6] + print composite[12] \ No newline at end of file