Question: Task E. Is a twin prime? A prime number N is called a twin prime if either N-2 or N+2 (or both of them) is
Task E. Is a twin prime? A prime number N is called a twin prime if either N-2 or N+2 (or both of them) is also a prime. For example, a prime 17 is a twin prime, because 17+2 = 19 is a prime as well. The first few twin primes are: 3, 5, 7, 11, 13, 17, 19, 29, 31 Add a function bool isTwinPrime(int n); that determines whether or not its argument is a twin prime. Change the main function to test the new code.
Task F. Next twin prime Add a function int nextTwinPrime(int n); that returns the smallest twin prime greater than n. Change the main function to test the new code.
Task G. Largest twin prime in range Add a function int largestTwinPrime(int a, int b); that returns the largest twin prime in the range a N b. If there is no twin primes in range, then return -1. For example: largestTwinPrime(5, 18) == 17 largestTwinPrime(1, 31) == 31 largestTwinPrime(14, 16) == -1 Change the main function to test the new code.
Please, it is necessary to use the functions and names given. Thanks.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
