Swift

Solution - Prime Numbers!

Our solution to the mini-project

Our Solution

Here is our solution. Your solution does not have to look like ours. If it works and is concise, then you’ve done it right!

let numbers = 1...100
for number in numbers {
    var prime = true
    var i = 2
    while i < number {
        if number % i == 0 {
            prime = false
            break
        }
        i+=1
    }
    if prime {
        print(number)
    }
}

Feel free to contact us if you have any questions.

chevron_up