Avatar ·

How to generate a random number in a given range in Android using Kotlin?

Hello everyone! I started learning Kotlin for Android development and encountered a simple but important task: I need to generate a random number in a specific range, for example, from 1 to 10 or from 50 to 100. I know that in Java, `Random` and `Math.random()` were used for this, but in Kotlin, as I understand, there are convenient functions of its own. The problem is that I tried several methods, but they work strangely. Here's what I'm doing: ```kotlin val random = Random() val number = random.nextInt(10) // This gives numbers from 0 to 9, but I need from 1 to 10 ``` I need the range to include both boundaries (for example, from 1 to 10 inclusive). I also heard that Kotlin has extensions for `Random`, but I'm not sure how to use them correctly in Android. Could you show a few reliable