Linear Congruence method for generating Pseudo Random Numbers | Function to generate random numbers ; Initialize the seed state ; Traverse to generate required numbers of random numbers ; Follow the linear congruential method ; Driver Code ; Seed value ; Modulus parameter ; Multiplier term ; Increment term ; Number of Random numbers to be generated ; To store random numbers ; Function Call ; Print the generated random numbers
def linearCongruentialMethod ( Xo , m , a , c , randomNums , noOfRandomNums ) : NEW_LINE INDENT randomNums [ 0 ] = Xo NEW_LINE for i in range ( 1 , noOfRandomNums ) : NEW_LINE INDENT randomNums [ i ] = ( ( randomNums [ i - 1 ] * a ) + c ) % m NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT Xo = 5 NEW_LINE m = 7 NEW_LINE a = 3 NEW_LINE c = 3 NEW_LINE noOfRandomNums = 10 NEW_LINE randomNums = [ 0 ] * ( noOfRandomNums ) NEW_LINE linearCongruentialMethod ( Xo , m , a , c , randomNums , noOfRandomNums ) NEW_LINE for i in randomNums : NEW_LINE INDENT print ( i , end = " ▁ " ) NEW_LINE DEDENT DEDENT