Without using recursion, please write a MATLAB function that accepts an input pa
ID: 3678162 • Letter: W
Question
Without using recursion, please write a MATLAB function that accepts an input parameter n and returns (outputs) a vector with the first ’n’ numbers in the series.
Example usage: x = fibonacci(10) x = 1 1 2 3 5 8 13 21 34 55 2
a. Provide the code and sample output for a simplified solution that only needs to work for inputs in the range 2 < n < 100. You can name your function fibnonacciSimplified.
b. Provide the code and sample output for a full solution that also works for any 0 < n < 100. You can name this function fibonacciFull.
Explanation / Answer
Answer=1
2) Program to print n fibonacci series using do while loop.
include
void main()
{
int a=0,b=1,n,i=2,c;
printf("Enter the no of terms");
scanf("%d",&n);
printf("%d%d",a,b);
do
{
c=a+b;
a=b;
b=c;
i++;
printf("%d",c);
}
while(i
}
3)
#include<iostream>
Using namespace std;
Unsigned int Fibonacci(unsigned int n)
{
If (n==0)
Return 0;
Else if (n==1)
Return 1;
Else return Fibonacci (n-1) + Fibonacci(n-2);
}
Int main()
{
Unsigned int n;
Cin >> n;
For (int i=1; i<=n; i++)
{
Cout << Fibonacci (i) << endl;
}
Return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.