Answers for "kotlin random number"

C#
13

kotlin random number

val randomNumber = (100..200).random()
Posted by: Guest on May-20-2020
1

kotlin Random()

val rnds = (0..10).random() // generated random from 1 to 9 included
Posted by: Guest on December-28-2020
-1

random class in kotlin

import kotlin.random.Random
 
fun rand(start: Int, end: Int): Int {
    require(start <= end) { "Illegal Argument" }
    val rand = Random(System.nanoTime())
    return (start..end).random(rand)
}
 
fun main() {
    val start = 5
    val end = 9
 
    for (i in 1..5) println(rand(start, end))
}
Posted by: Guest on November-25-2020

C# Answers by Framework

Browse Popular Code Answers by Language