206k views
0 votes
A statistics teacher wishes to create a program on her calculator that generates a random even integer. The command built in the calculator to generate a random positive integer is RANDOM(a,b). This command generates a random integer between integers a and b (and including a and b). Which of the following lines of code will ensure that the random integer generated will be even?

1) RANDOM(1,100)
2) RANDOM(2,100)
3) RANDOM(1,99)
4) RANDOM(2,99)

1 Answer

5 votes

Final answer:

The correct command to generate a random even integer between a specified range, in this case, is RANDOM(2,100), since both 2 and 100 are even numbers.

Step-by-step explanation:

To generate a random even integer using the RANDOM(a,b) command on a calculator where a and b are the inclusive limits of the range, the starting point a must be even and b must be at or after the first even integer at the starting range. Out of the choices given in the question, the correct command to ensure an even random integer is generated would be RANDOM(2,100). This command starts at 2 (the first even integer) and includes every even number up to and including 100 since every other number after 2 is also even in this sequence (2, 4, 6, ..., 100).

To generate a random even integer using the given command RANDOM(a,b), we need to ensure that the range of integers includes only even numbers.

The only option in the given choices that guarantees this is RANDOM(2,100), as it starts from the even number 2 and includes all even numbers up to and including 100.

Therefore, the line of code that will ensure a random even integer is generated is the second option, RANDOM(2,100).

User GlenRSmith
by
8.1k points