def fnum_aleatorio():
a=22695477
b=1
m=2**32
semente=3
num= semente
num_aleatorio = (num*a + b)%m
if num_aleatorio <= m//2:
return 0
else:
return 1
I have this function, I want it to return 0 or 1 depending on the random number created. I have a, b, semente e m
as fixed parameters! I'm trying to make a sequence of random numbers by the method of linear congruences. that is, my num_aleatorio
should change. theoretically, this function should create a logical sequence that accompanies num_aleatorio = (num*a + b)%m
, but I do not know how to do that. type, the next time I called the function, num
would become num_aleatório
old