hi,this sandy patel
i have problem related to random number genre.
i don't understand from which is number from i have to start my program?
and,upto witch number i have to go?
The following steps describe the algorithm.
Step 1: Enter an odd 4-digit integer seed number that is not divisible by 2 or 5.
Step 2: Multiply the seed number by 97.
Step 3: Extract the lower 4 digits of the result produced by step 2.
This is the procedure for Step 3.
3a: Divide the number by 104
3b: Keep the integer part of the result of step 3a.
3c: Multiply the result, in 3b, by 104.
3d: Subtract this result from the number produced by step 2.
Use this random number as the new seed.
Step 4: Repeat Steps 2 and 3 to generate as many random numbers as required.
Write a program that tests the effectiveness of this algorithm.
To do this we will generate a large number of pseudorandom integers, record them and
investigate the randomness of the numbers produced.
However, the algorithm above will produce numbers up to 9999. To check the randomness of
the output we would like to record the number of times each integer was generated but with
10000 numbers this would be a tedious process. Our task is to make a quick check possible
within the limits of our resources. The quickest way to present the results is on the screen but
it would be impractical to present all 10000 integers. To overcome this we will limit the test
to random numbers between 0 and 9. These can then be easily tabulated on the screen.
Your task then is to generate a large number (maximum 1000) of pseudorandom integers
between 0 and 9. You will use the algorithm above to generate the 4 digit pseudorandom
numbers and from each extract one of the 4 digits to produce a random number of 0-9.
Start by initialising 10 variables, used as counters, to zero. The counters will keep a sum of
the occurrence of each random digit generated. Print out the number of 0s, 1s, 2s etc. that
occurred and the percentage of time they occurred.
A sample output is shown below.
hi,this sandy patel