IsPrime
func isPrime(num: Number): Boolean { for (var i = 2; i < num; i += 1) { if (num % i == 0) return false } return true}
print(isPrime(17)) # trueprint(isPrime(97)) # trueprint(isPrime(18)) # falseprint(isPrime(54)) # false
This function checks if a number is prime by looping through all the factors needed for it to be composite.