Question: / * PROJECT 3 - Complex Formula Let's create a program with a few functions to satisfy a set formula with several components. Read the

/*
PROJECT 3- Complex Formula
Let's create a program with a few functions to satisfy a set formula with several components.
Read the code and all of its comments. Follow the instructions contained in the comments to complete this project.
Remember, do not delete or change anything already in this file.
When finished, compress this project into a ZIP folder and submit it to Canvas.
*/
/*
Create a program using functions that satisfies the following sets equation.
A ={x : (x is prime or x is divisible by 5) and x is a Fibonacci number and x <=1000000}
The main function is completed for you. Your job is to create the functions it calls.
1. Include the iostream, cmath, and vector libraries. (10)
2. Create the following four functions.
isPrime(int input)- Returns true if input is prime, false if it is not.
To receive credit, you may use no other function besides sqrt here. (20)
isXMultipleOfY(int input, int divisor)- Returns true if input is divisible by divisor,
false if it is not. (15)
inSequence(int input, int divisor)- Returns true if either of the two functions above would return
true, false if it would return false for both. (15)
fibonacci(int limit)- Returns a vector containing every Fibonacci number up to and including limit.
To receive credit, the only functions you may use are vector functions and abs. You must also
account for all possible integer inputs, including negatives and zero. (20)
*/
int main(){
//fibonacciSeries holds the series of Fibonacci numbers up to 1000000.
//sequence will contain the contents of fibonacciSeries which are prime or multiples of 5.
vector fibonacciSeries = fibonacci(1000000);
vector sequence;
//Populates sequence with the Fibonacci numbers that satisfy either of its conditions.
for(auto it : fibonacciSeries){
if(inSequence(it,5)){
sequence.push_back(it);
}
}
//Prints sequence to the terminal, each value separated with a space.
for(auto it : sequence){
cout<< it <<"";
}
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!