x = 1 toggle = 0 counter = 0 while x<1000000: x+=1 for i in range(2,x): if not x%i: toggle=1 if not toggle: counter+=1 toggle=0 print(counter)