I’m trying to get random number and mod 2
Help me if you know how ㅠㅠ
Since your question isn’t very detailed, I’m not sure if this is what you are looking for, but here it is nevertheless:
import kotlin.random.Random
fun main()
{
val randomNum = Random.nextInt()
val isEven = randomNum % 2 == 0
println("$randomNum isEven = '$isEven'")
}
2 Likes
Thanks!
Though in this case it might be better to use Random.nextBoolean()
.