Set the number range to quickly generate random numbers in batches. Provides random number generation functions for a variety of programming languages.
How to generate random numbers in different programming languages
| Language |
How to generate random number |
| Java |
Math.random()*10 |
| PHP |
rand(0,10) |
| JavaScript |
Math.floor(Math.random()*10) |
| Python |
random.randint(0,10) |
| Go |
fmt.Println(rand.Intn(100)) |
| OC |
arc4random_uniform(10 + 1) |
| Swift |
arc4random() % 10 + 1 |
Tips: There are many different algorithms for generating random numbers, which are generally called random number generators. The most important characteristic of a random number is that it has nothing to do with the number that is generated in the back. All such algorithms generate pseudo-random numbers because the real random numbers are generated using physical phenomena such as coin toss, dice, and atmospheric noise.