Skip to content

Instantly share code, notes, and snippets.

@robertmryan
Last active February 28, 2016 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertmryan/06ef1a474d15267b4b45 to your computer and use it in GitHub Desktop.
Save robertmryan/06ef1a474d15267b4b45 to your computer and use it in GitHub Desktop.
@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"
}
}
@RcubDev
Copy link

RcubDev commented Dec 12, 2015

Thanks for helping me out!

@robertmryan
Copy link
Author

@Rcub3161 No problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment