Last active
February 28, 2016 23:22
-
-
Save robertmryan/06ef1a474d15267b4b45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func calculateButton(sender: AnyObject) { | |
if let value = Int(number.text!) { | |
var isPrime = true | |
if value == 1 { | |
isPrime = false | |
} | |
for var i = 2; i < value; i++ { | |
if value % i == 0 { | |
isPrime = false | |
} | |
} | |
if isPrime { | |
resultLabel.text = "\(value) is prime!" | |
} else{ | |
resultLabel.text = "\(value) is not prime!" | |
} | |
} else { | |
resultLabel.text = "Please enter a number in the box" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for helping me out!