why first print and second print got different result from function in python

Viewed 25

so i have func and i called it with lcg. the func have return value and i got the value i want.

6 7 2 11 14 15 10 3 6 7 2 11 14 15 10 3 # this is the result from func lcg

but after i called the func and print tes5, i just get result 3

i don't know what wrong, so please help me to fix it

here's the code:

def lcg(n, m):
    a = 11
    c = 5
    dec = n
    m = m * 4
    for i in range(0,m):
        LCG = ((a*dec)+c) % m 
        print(LCG, end= ' ') # result = 6 7 2 11 14 15 10 3 6 7 2 11 14 15 10 3
        dec = LCG
        
    return LCG

tes5 = lcg(3, 4)
print(tes5)

print(tes5) # result = 3
0 Answers
Related