Question: (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

(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 vVx and 2Vx. The logic is that, if there exists a number z 2 Vx that divides x, then x-yz for some number y
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
