Ask Question
9 November, 14:32

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.

+1
Answers (1)
  1. 9 November, 15:56
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers