fork(4) download
  1. def eratosthenes(n):
  2. arr=list(range(n+1))
  3. p=1
  4. while(True):
  5. f=0
  6. j=2
  7. while(j<=n):
  8. if (arr[j] != 0) & (arr[j] > p) :
  9. p=arr[j]
  10. i=j+1
  11. while(i<=n):
  12. if (arr[i] != 0) & (arr[i]%p==0):
  13. print(arr[i],end=' ')
  14. arr[i]=0
  15. f=1
  16. i += 1
  17. j += 1
  18. if (f==0):
  19. break
  20.  
  21. eratosthenes(15)
  22.  
Success #stdin #stdout 0.01s 27728KB
stdin
Standard input is empty
stdout
4 6 8 10 12 14 9 15