Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting the lower limit for random number function

Tags:

java

jsp

How to set the lower limit for this

<%= (int) (Math.random() * 60) %>

Now it give number from 0 to 60 if i want number in between 50 to 60 so how to set it. Thanks

like image 669
user667340 Avatar asked Mar 05 '26 09:03

user667340


1 Answers

    <%= (int) (Math.random() * 10 + 50) %>

That is,

   <%= (int) (Math.random() * (Max-Min) + Min) %>
like image 94
Vincent Ramdhanie Avatar answered Mar 07 '26 21:03

Vincent Ramdhanie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!