```
def prime_finder(n):
# Write your code here
t = [i for i in range(2,n+1)]
for i in t:
for j in t:
if (j % i == 0) & (j != i) & (i >= 2):
t.remove(j)
return t
print(prime_finder(11))
```

I used memoization to convert time complexity to space complexity.

In my solution I didn’t use a factor list at all because if even a single factor beyond 1, and the candidate prime itself is found then we automatically know it’s not a prime number. So we break the factor loop for that candidate prime and move on to the next. We also know that if the inner loop ever finishes without breaking it’s because it didn’t find a 3rd factor, therefore the number is prime. Good luck to everyone on their coding journey!

This is the first time I do the Prime Number Finder on Python; I have used other languages before.

On the isPrime function, I first identify non-prime number to eliminate; if the number modulo the iteration equals zero but the iteration does not equal the number, it is a good indication that it is not a prime number; the code then breaks; otherwise, it would be a prime number.

Hi all,

I completed this challenge (with some youtube assistance on the prime algorithm). I wanted to know if someone could perform a quick code review and provide any recommendations on how this could be improved. Thanks!!

```
def is_prime(num):
if num == 1 or num == 0:
return False
else:
for i in range(2,num):
if num % i == 0:
return False
break
else:
return True
def prime_finder(n):
listofnums = []
for i in range(n+1):
if is_prime(i) == True:
listofnums.append(i)
return listofnums
print(prime_finder(11))
```

I completed this challenge by cancelling multiples of 2,3,4,5,6 and 7

I’m sure there must be a more efficient way, nonetheless it worked

```
def prime_finder(n):
prime_nums = []
for n in range(2,n+1):
if n == 2 or n ==3 or n == 5 or n == 7:
prime_nums.append(n)
if n%2 != 0 and n%3 != 0 and n%4 != 0 and n%5 != 0 and n%6 !=0 and n%7 != 0 and n not in prime_nums:
prime_nums.append(n)
print(prime_nums)
return(prime_nums)
prime_finder(11)
prime_finder(200)
```

We will never knock invention, ingenuity and initiative, so your *less efficient* way is cool with us. Your admission of acceptance that there may be a more efficient way is the first step in working toward it. Accept that our code is not perfect is always the best place to start. Kudos.

I would definitely want to take that code back to the drawing board and look for ways to apply the principle of it without all the excessive logic. It can be done, and in all fairness, I’ll leave that to you.

I think one simple solution is to assume that the number is a prime and then test if it isn’t. If that’s the case, remove it from the list. Here is my solution:

```
def prime_finder(n):
# define empty list to store primes:
out = []
# loop over each number in the range:
for x in range(1, n+1):
# assume it is prime:
out.append(x)
for y in range(2, x):
# if it is not prime, get out of the list
if x % y == 0:
out.pop()
break
# remove 1 because it is not prime
out.remove(1)
return out
```

Hi there, I just wanted to add a little bit to your solution. I’ve tested it alongside my solution and found out that for 2nd test: **prime_finder(200)** yours include some numbers that are not actually prime numbers: your solution returned a list of 50 numbers, mine - a list of 46 numbers. Upon closer inspection I realised your solution does not account for the fact that 121, 143, 169, 187 are not prime numbers. That happend because the code hasn’t accounted for multiples of 11, 13, 17 etc. The longer the range, the more chance will be that some multiples haven’t been accounted for.

My basic solution