+ 73
@vitya how did you generate the random numbers?
76 Antworten
+ 44
Well I used Math.random() method together with Math.round() method. A multiplier is used to define the maximum value of the generated number. Those are 3 things required to do that.
This is how it works.
Math.random() generates a long decimal number. It's not truly random, but it's unpredictable so one can call it "random".
However, I don't need the precision of a long decimal so I use one of the method to round the number. In that code I used Math.round() method, which rounds the number up.
Math.floor() method can be used instead of Math.round(), but it rounds the number down. Math.ceil() is similar to Math.round(). It also rounds the number up.
+ 56
Vitya Thanks for your help👍😁😁!!!
+ 37
"I set the browser to accept all cookies"
It's show and tell time. I decided to visualize my explanation of creating random numbers. For that I reworked the prototype code, added more controls and ways to get a random number.
I hope it will help you understand this topic better. Have fun with it!
https://code.sololearn.com/Waji2iM7FwNj/?ref=app
+ 10
Mohammad Naveeth you know that's probably a fake account you're talking to rignt?
+ 9
Hey sir in python you can use for loop for that
+ 1
Hello
How old are you
+ 1
Ok tq
+ 1
Cozmo G from outer space Are you crazy ?
+ 1
Sorry kate dambar
no matter
+ 1
Can you please help me to learn c++
Ok
0
19
0
Hello
0
What question
0
What do you say? Where are you from?
0
I am from India
0
Am I talking to you?
0
Yes I think
0
Kate dambar
0
Are you crazy?
0
Have you ever traveled to America?