Question: please finish the tasks in C + + , thanks Task 1 : Checks if a number is prime or not. bool isPrime ( int
please finish the tasks in Cthanks
Task : Checks if a number is prime or not.
bool isPrimeint n
This function checks if a number is prime or not
Input: n an integer
Output: true if n is prime, false otherwise
For example, isPrime returns true
NOTE: is not a prime number
Your TODO: Implement this function
Task : Find all pairs of prime numbers that sum up to a given even number.
void findPrimePairint n
This function finds all pairs of prime numbers that sum up to n
Input: n an integer
Output: the pairs of prime numbers p q such that n p q
For example, findPrimePair outputs:
NOTE: you should output all pairs of prime numbers that sum up to n and then print them in ascending order of p
NOTE: please DO NOT print the same pair twice, eg and are the same pair, only print the first one
NOTE: if n is not an even number, print n is not an even number" and return
Your TODO: Implement this function
cout endl;
Task : Find all even numbers in the range lower upper that can be expressed as the sum of two prime numbers in at least two different ways.
void findPrimePairInRangeint lower, int upper
This function finds all even numbers in the range lower upper that can be expressed as the sum of two prime numbers in at least two different ways
Input: lower bound, an integer include this number
Input: upper bound, an integer include this number
Output: a list of even numbers in the range lower upper that can be expressed as the sum of two prime numbers in at least two different ways
For example, findPrimePairInRange outputs:
NOTE: and are considered as one way, not two ways. and are considered as two ways.
Your TODO: Implement this function
cout endl;
Task : Find all even numbers in the range that can be expressed as the sum of the given prime number and another prime number.
The given prime number is read from filesprimeXtxt where X is the number of test cases and the folder files is provided in the zip file.
The outputs should be split by a space, such as
void findEvenNumbersstring path
This function finds all even numbers in the range that can be expressed as the sum of the given prime number and another prime number
cout "Reading prime number from path endl;
ifstream finpath; read prime number from this file
int prime;
fin prime;
cout "Prime number: prime endl;
Your TODO: Implement this function
cout endl;
fin.close;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
