Instead of using nested loops to check every possible divisor of a potential prime number, we can cut down on our searching by checking potential primes against a list of prime numbers that we've already generated. If any of those prime numbers divide evenly into our potential prime, then we'll know that it isn't prime, and we can continue searching at the next higher value.
Write a program prime_finder2.py
that asks the user the maximum value of primes they'd like to consider, then use the strategy described above to create a list of primes up to that number and print it out.
# create an empty list for storing primes
# have the user enter the highest value of prime to consider
# set up a loop to run from 2 to that highest value
# assume that the current value is prime
# go through all the prime in the prime list
# if current value is evenly divisible by this prime
# we know current value is not a prime, so break out of loop
# if we got through loop and number was never evenly divisible:
# it must be a prime! add it to our list of primes
# after going through all values, print out the list of primes