
The algorithm you described is known as the Sieve of Eratosthenes. It is a simple and efficient algorithm for finding all primes smaller than a given number n.

Here is a Python implementation of the Sieve of Eratosthenes:

```python
def sieve_of_eratosthenes(n):
    primes = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (primes[p] == True):
            for i in range(p * p, n+1, p):
                primes[i] = False
        p += 1
    prime_numbers = [p for p in range(2, n) if primes[p]]
    return prime_numbers

print(sieve_of_eratosthenes(30))
```

This code first initializes a list of boolean values representing the numbers from 2 to n. It then iterates over the numbers from 2 to the square root of n, and for each number, it marks its multiples as not prime. The remaining numbers in the list that are still marked as prime are the prime numbers up to n.

The output of this code will be:

```python
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
```

This is the list of all prime numbers less than 30.
