Dec-06-2017, 06:46 PM
(This post was last modified: Dec-06-2017, 06:46 PM by ehammarlund.)
Thanks! I am trying to begin at index value= 2x (whatever x is as per the range loop) and replace the number in the list with "False" throughout the whole list, every X steps.
As an example for x=3, the list
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
would become(new changes underlined)
1,2,3,4,5,False,7,8,False,10,11,False,13,14,False,16,17,False,19,20
and if I then ran that same function for x=5 it would become (new changes underlined):
1,2,3,4,5,False,7,8,False,False,11,False,13,14,False,16,17,False,19,False
(yes, I know that my actual code includes x=2 and x=4, but I left them out because they make it hard to illustrate what I'm doing.)
Eventually the list would only contain "False" and primes.
I can then either output a list of primes if I want them or can leave the list as-is for a very quick way to check the primacy of a number.
If I succeed, I'll choose which output to use later on. I don't know yet whether there's a material speed difference in
a) testing "is list[index]==False"
versus
b) testing "is [item] contained in list"
As an example for x=3, the list
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
would become(new changes underlined)
1,2,3,4,5,False,7,8,False,10,11,False,13,14,False,16,17,False,19,20
and if I then ran that same function for x=5 it would become (new changes underlined):
1,2,3,4,5,False,7,8,False,False,11,False,13,14,False,16,17,False,19,False
(yes, I know that my actual code includes x=2 and x=4, but I left them out because they make it hard to illustrate what I'm doing.)
Eventually the list would only contain "False" and primes.
I can then either output a list of primes if I want them or can leave the list as-is for a very quick way to check the primacy of a number.
If I succeed, I'll choose which output to use later on. I don't know yet whether there's a material speed difference in
a) testing "is list[index]==False"
versus
b) testing "is [item] contained in list"