+ 2
I have created an algorithm for generating random numbers, however even after making provisions there are problems! Help me
Even after making provisions that the number doesn't exceed the seed and it doesn't become negative, I am still getting numbers exceeding the seed and negative numbers too. https://code.sololearn.com/WECN7NWn1b5F/?ref=app
2 ответов
+ 1
Thanks
0
I didn't get negative numbers, but imagine you got -150 in your first step. That's lower than 4, so it skips the while loop. After that, as it's negative, you invert it to 150.
That's the reason for your seed exceed.