jeudi 3 novembre 2016

Swift random number based on other random number

I want to call my two function like so. So num1 = 1-9 and num2 = 10-99

let num1 = easyDivisionNumbers()
let num2 = easyDivisionNumbers(x: num1)

So this is my code so far. How would I fix my easyDivisionNumbers(x: Int) so it outputs a random number between 10-99 so that num1/num2 == 0 everytime

//Division
public func easyDivisionNumbers()-> Int {
    let number: Int = Int(arc4random_uniform(10) + 1)
    return number
}
public func easyDivisionNumbers(x: Int) -> Int {
    let number: Int = Int(arc4random_uniform(100) + 10)
    while ((x/number) != 0){
         let number: Int = Int(arc4random_uniform(100) + 10)
    }
    return number
}




Aucun commentaire:

Enregistrer un commentaire