In my book, it says the way to produce a random integer from, for example, 1-50 is to use srand() % 50 + 1.(adsbygoogle = window.adsbygoogle || []).push({});

But wouldn't that give "1" the chance of showing up more often than other numbers?

If srand is 0, then the random result is 1. If srand is 50, then the random result is also 1. The other numbers only have one chance of showing up, while "1" has two. Or am I missing something?

Thanks.

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Programming random integers

**Physics Forums | Science Articles, Homework Help, Discussion**