The Fibonacci series is given as follows:
1, 2, 3, 5, 8, 13, 21, ...
How can I write a script which calculates and prints the n-th Fibonacci term (for n>2
), where n
is inputed by the user.
This is what I ve tried:
n=input( n: );
while(n < 3)
disp( must enter number >= 3 )
if(n < 3)
fprintf(
Please re-insert again!!
)
n=input( n: )
else (n >=3)
fibf(n)=fib(n-1)+fibf(n-2);
end
end
fprintf( the nth value of n is : ,fibf(n) )
but this failed to print out the correct solution.