Table Lookup
- Suppose that you are given a list of prime numbers less than 100
([
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73, 79, 83, 89, 97]).
- Repeatedly ask the user to input an integer between 1 and 100.
- If the integer is a prime number, report its position in the list.
- If the integer is not a prime number, report that it is not.
- If the integer is greater than 100 or less than 1, exit the loop
and end the program.
The program may run as follows:
Input an integer between 1 and 100 -- 4
4 is NOT a prime number.
Input an integer between 1 and 100 -- 5
5 is a prime number with index 2
Input an integer between 1 and 100 -- 11
11 is a prime number with index 4
Input an integer between 1 and 100 -- 0