I need a very simple random number generator function that takes a input parameter as a range something like:
int randomNumberGenerater(int range) {
return (int) (Math.random() * range);
}
The trouble is when the range is equal to 1, it will always output 1 instead of alternating between 0 and 1. How can I fix that with a generic solution that works with any range if possible.