Generate random number of certain amount of digits

后端 未结 7 1927
不知归路
不知归路 2021-01-18 10:51

Hy,

I have a very Basic Question which is :

How can i create a random number with 20 digits no floats no negatives (basically an Int) in Swift ?

Than

7条回答
  •  Happy的楠姐
    2021-01-18 11:39

    you can create a string number then convert the number to your required number.

    func generateRandomDigits(_ digitNumber: Int) -> String {
        var number = ""
        for i in 0..

    for 20 digit you can use Double instead of Int

提交回复
热议问题