Once again I am in need of help... here\'s the program that I need to write. 1.
ID: 3618695 • Letter: O
Question
Once again I am in need of help...here's the program that I need to write.
1. Write a recursive function Fibonacci ( ) that will generate andprint the nth Fibonacci number. n is the inputyou read from the user in the main program. Your main ( ) functionshould call the recursive Fibonacci ( ) function. The main ( )program then should get the result from the Fibonacci () functionand print it.
Here is the definition of the Fibonacci () function:
Fibonacci (0) = 0
Fibonacci (1) = 1
Fibonacci (n) = Fibonacci (n 1) + Fibonacci (n 2) ,for all n > 1
2. Write an iterative (non-recursive) function multiple_of_5 ()that checks if a number is
divisible by 5.
Your main ( ) program should get the number from the user, and thencall the multiple_of_5 () function. After getting the result backfrom the function, your main program should print out whether thenumber is a multiple of 5 or not.
3. In the main () function, first ask the user to enter a positivenumber to calculate the Fibonacci () of that number. Keepasking for a positive number until the user enters one.Once the user enters a positive number, call the Fibonacci ()function with that number and print the result in the main ()function.
After this task is completed, call the the multiple_of_5 ()function and in the main () program
print out whether or not the number is a multiple of 5.
Please note that all printing is supposed to be done in the main()program. You should not have any cout commands inthe Fibonacci () or multiple_of_5 () functions.
Here is what your program should look like:
#include <iostream>
using namespace std;
int Fibonacci (int);
int multiple_of_5 (int);
int main ( )
{…}
int Fibonacci (int n)
{…}
int multiple_of_5 (int n)
{…}
A partial example of a running program is shown below, withthe user's input shown in italics.
Please enter a number:
-4
The number should be positive.
Please enter a number:
-10
The number should be positive.
Please enter a number:
-1
The number should be positive.
Please enter a number:
6
Fibonacci (6) = 8
6 is not a multiple of 5.
thanks! :)
Explanation / Answer
please rate - thanks #include using namespace std; int Fibonacci (int); int multiple_of_5 (int); int main ( ) {int n; coutn; while(nRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.