Mini Project - Prime Numbers!

Finding prime numbers with Swift

Prime numbers?

In this project, we will write a program that lists all the prime numbers within a certain range of numbers. A prime number is a number that cannot be divided by any number but 1 or itself, for the answer to be a whole number. For example, 2,3,5, etc. In the program, let’s use an assortment of loops.


First, create a list of numbers from 1 to 100 (or any range you’d like). Then, use a for loop to loop over each individual value in that list. Finally, use a while loop on each individual number ‘x’, looping over all numbers smaller than ‘x’ to see if ‘x’/one of the numbers is a whole number. If it is, then the number is not prime and should be tossed, then move on to the next! Have a crack at it! Good Luck!