hi im having trouble creating a linear congruential generator in MatLab, the ones that I found online work quite different than mine. then im trying to print values of the m and a (relatively prime, m being a large prime obviously) and check when the cycle is full. I know all the math stuff, im getting used to matlab and its hard to implement this for me even though i should know. my program looks like this:
M = [];
for m = 100:10000;
M(m) = m;
A = [];
for a = 2:(m-1);
A(a) = a;
B = [];
R = [];
for n = 1:1000;
R(n) = n;
B(n) = A(a) * n;
K = [];
K(n)=mod(B(n),M(m));
n=n+1;
a=a+1;
m=m+1;
if K(n) == R(n)
print (m)
print (a)
print ('the cycle is done')
end
end
end
end
also im not too familiar with MatLab so im probably creating arrays the wrong way. thanks in advance.