Prev: modified bessel functions
Next: When a function returns a matrix, getting nth element all in same line of code
From: Wayne Carter on 2 Mar 2010 21:05 Hi I am writing a program for the fibonacci sequence. So far the program I have is function fibonacci = fib(N) num=1; num2=1; num3=0; count=1; fib=[0,1]; while count<N-1; fibs(1,count+2)=fib num3=num2; num2=num; num=num2+num3; count=count+1; end My question is how would I write a program for a modified fibonacci sequence. Like if I gave the program a initial number, a second number and how many numbers I want in my sequence how would I update my program? Like lets say I start with 8 and 10 and want 4 numbers in the sequence so that it reads 8, 10, 18, 28 how would I rewrite this program to make it work. Thanks |