repl.it
@AbstractToast/

Random number

Swift

No description

fork
loading
Files
  • main.swift
  • main
main.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import Foundation
    srandom(UInt32(time(nil)))
func getRandomNum(_ min: Int, _ max: Int) -> Int {

        return Int(random() % max) + min
}

// Print random numbers between 1 and 10
print(getRandomNum(1, 10))
print(getRandomNum(1, 10))
print(getRandomNum(1, 10))
print(getRandomNum(1, 10))
print(getRandomNum(1, 10))
Fetching token
?