# Primality Testing in C Programming

(Q1) Primality Testing 10 marks Recall that a number is a prime number if its only divisors are 1 and itself. Write a C program that prints "Enter a number: ” to stdout and reads an unsigned integer from stdin. (Use scanf to do so. You do not need to perform any error checks.) Your program should print “x is a prime number." where x is the number you entered, if x is a prime number. Otherwise, it should print "x is not a prime number" The exit code of your program should be 0 For full marks, your program must meet the following requirements concerning the implementation: You should be able to handle any unsigned integer that fits in 64 bits. When testing whether there exists a number y that divides x (and, thus, x is not a prime number), restrict yourself to integers y s 2vx. Precisely, the largest number y you test whether it divides x should be between vx and 2Vx. The logic is that, if there exists a numberz 2 Vx that divides x, then x-yz for some number y vx and y also divides x. The reason why the permissible range of y is [2,2Vx] is explained in the next bullet. For full marks, find the maximum value of y you test without calling the sqrt library function (which is a loating point function). Instead, use C's bit shift operator to calculate the maximum value of y you need to test. This may return a number as large as 2/x Implement your program in a file primetest.c, place this file into your a4 directory and commit it to SVN.