Hi all, I realise this is not a Kali question per se, but I thought a few contributors here could help me.
At a CTF recently there was a challenge to find all the prime numbers between 1 and 2 Trillion.
I know this can be discovered using the Sieve of Eratosthenes, and I am trying to write it in Python.
Let me say this, I dont want someone to just write it for me, I can google that, I would like someone to help me with the logic.
So far, I take the number, n as the first argument of the script, I have been using 30 as a test figure.
I make a list from 2 to the target value:
for x in range(2, arg1):
list1.append(x)
If I understand the sieve correctly, what I need to do is, multiply 2 by 2,3,4,5,6,7,8,9 etc, until the product is equal to or more than the target value. Any results that are whole numbers, remove them from the list. Then do the same for 3 and for 5, and my list are all the prime numbers.
Can someone suggest my next step?
Thanks