def SieveOfEratosthenes(n):
          # j = n
          # n = 15*n
          nums = {}
          for i in range(2, n+1):
              nums[i] = 1
          for i in nums:
              if nums[i] == 1:
                  k = 2
                  m = k*i
                  while m <= n:
                      k+=1
                      nums[m] = 0
                      m = k*i
          ans = []
          for k in nums:
              if nums[k] == 1:
                  ans.append(k)
          return ans
      
      Python language logo

      Sieve Of Eratosthenes

      sieve
      prime
      Primes

      Let's you find all prime numbers upto a certain number (which it takes as an argument)

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.