(Kotlin)I Need HELP! How to Mod?

#1

I’m trying to get random number and mod 2
Help me if you know how ㅠㅠ :cold_sweat:

#2

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
#3

Thanks!
:smiling_face_with_three_hearts:

#4

Though in this case it might be better to use Random.nextBoolean().