Hi
I have written very simple function, which code I paste below. The
thing is that it produces completely unexpected results. I paste them
below. Please let me know if this is a bug or I just do something
completely wrong. I change in tests only the modulus M.

def MLCG_S(B,M,N,x0):
    x = x0
    L = []
    for i in range(1,N):
        x = Mod(B*x, M) #MLCG(B,M,x)
        print x==B
        print (B-M)
        print (x-M)
        print M-B
        print M-x
    return L;
____________________2^31-1____________________
Invocation: LCG_16807 = MLCG_S(16807,2^31-1,2,1);
Result:
True
-2147466840
16807
2147466840
2147466840
___________________2^20-1____________________
Invocation:LCG_16807 = MLCG_S(16807,2^20-1,2,1);
Result:
True
-1031768
16807
1031768
1031768
___________________2^10-1____________________
Invocation:LCG_16807 = MLCG_S(16807,2^10-1,2,1);
Result:
True
15784
439
-15784
584

Above, not only the first two differences are different, but also the
last two differences are different!

Cheers

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to