Test Informed Learning with Examples

Logo

Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.

Menu

Prime or not

Write a program to determine whether an integer is prime or not. A prime number is a natural number greater than 1 that has only two positive divisors: itself and 1.

For example, the prime numbers less than 200 are: 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, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199. You can use them as test cases for your program.

Remember, you should not only tests whether primes are detected correctly. You should also test other numbers and check your program says they are not prime. Also try with negative numbers.

Insist that the students test their programs by giving them ideas or
pointers about the test data to use.