Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

#Day40 #100DaysChallenge- Matlab Loops|Fibonacci Series

#Day40-Fibonacci Series
Task:
Write a code for Fibonacci Series by take user input for number of  terms in the series.

  1     1     2     3     5     8    13    21    34    55

Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those
Matlab code

function a=fibonacciseries(x)
a(1)=1;
a(2)=1;
for lo=3:1:x
    a(lo)=a(lo-1)+a(lo-2);
    end
end

Sample Input and Output
>> a=fibonacciseries(10)


a =

     1     1     2     3     5     8    13    21    34    55

>> a=fibonacciseries(15)

a =

     1     1     2     3     5     8    13    21    34    55    89   144   233   377   610

 Click Here for Video Description



No comments

Popular Posts

Followers