Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have this formula
xi+1 = (p1*xi + p2)%(2**N)
i need to generate 2 lists:
xlist and ylist where xlist=[X0, X1,X2,.....Xn-1]
and
ylist = [X1,X2,.....Xn] where:
X0=Seed as 56 for example , n is number of samples

i need your help i wont like to earn python any more and i have tried some solution:

What I have tried:

Python
p1 = 15436
p2 = 65
n = 22
seed = 56
list1 = []
def squares(N):
	seed = 56
	x0 = seed
	for i in range(N):
		xi = (p1*x0 + p2)%(2**N)
		x0 = xi
		yield xi
for n in squares(1000):
	print(n)
Posted
Updated 25-Feb-18 22:42pm
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900