Random number in [-10,10]

Diyashvir Babajee shared this question 3 years ago
Answered

Hello I am trying to obtain a random integer in [-10,10] excluding zero in button scripting.

I have used the scripta=If[RandomBetween[-10, 10]==0,RandomBetween[-10, 10]+1,RandomBetween[-10, 10]]


However, upon clicking the button sometimes i got a=0

Any help will be greatly appreciated.

Thanks,

Rajiv

Comments (2)

photo
2

hello

the three random numbers are different so the condition is not you want

you can do (randombetween[0,1]*2-1)*randombetween[1,10]

or randomelement[{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10}]

saludos

photo
1

Thanks

© 2020 International GeoGebra Institute