[Tutor] Sieve of Erastthotenes without sofisticated tools

Dave Angel davea at davea.name
Mon May 4 12:00:24 CEST 2015


On 05/04/2015 03:19 AM, yvan moses Levy wrote:
> My code is wrong!

You'd find it a lot easier to get responses if you'd say in what way the 
code is wrong.  If you get an exception, show the full traceback.  If 
you get printed results, show what you expected, and what you got 
instead.  If it hung, or crashed the OS, or ran out of memory, say so.

> I tried and tried
> But I'm very isolated and It's hard without consultation with a tutor
> <code>from math import sqrt
> def holeofStrainer():
>    bigList = [False, False] + [True]*100
>    print("line 4 - bigList : ", bigList)
>    for num in range(2, 101):
>      print("line 6 - num : ", num)
>      for x in range(bigList[2], bigList[int(sqrt(num)) + 1]):

What did you expect this to do?  What is bigList[2] ?  What is 
bigList[int(sqrt(num)) + 1] ?  Are these reasonable values to put into a 
range() function?



>        print("line 8 x : %d"%x)
>        if num % x == 0:
>          print("line 10 {0} divise par {1} = {2} ".format(num, x, num/x))
>          bigList[num] == False
>          print "bigList[{0} == {1}]".format(num, bigList[num])
>        bigList[num] == True
>
>      for multiple in range (2, int(101/num) + 1):
>        bigList[multiple] = False
>    return(bigList)
> print("the last result of bigList {} ".format(holeofStrainer()))</code>
> I WANT TO KNOW WHILE THE EXECUTION DO NOT GOING DOWNWARD
>
> --
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
>


-- 
DaveA


More information about the Tutor mailing list