Ask Question
11 November, 10:28

A simple random generator is obtained by the formularnew = (arold+b) %mandthen settingroldtornew. Write a program that asks the user to enter an initialvalue forrold. (Such a value is often called a seed). Then print the rst 100 randomintegers generated by this formula, usinga = 32310901, b = 1729, andm = 224.

+4
Answers (1)
  1. 11 November, 11:26
    0
    The solution is written in Python

    a = 32310901 b = 1729 m = 224 rold = int (input ("Enter an initial value: ")) for i in range (100) : rnew = (a * rold + b) % m print (rnew) rold = rnew

    Explanation:

    Firstly, declare variable a, b and m and initialize them with preset value as given in the question (Line 1-3).

    Next, use input function to prompt use to input an initial value and then assigns it rold variable.

    Create a for-loop that will run for 100 iterations (Line 7). Next, apply the random generator formula to generate a random number and assign it to rnew (Line 8). Print the rnew (Line 9) and set the current rnew to overwrite the value of rold (Line 10).

    The program will generate 100 random integers.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “A simple random generator is obtained by the formularnew = (arold+b) %mandthen settingroldtornew. Write a program that asks the user to ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers