fibbonacci squared but this always field

Back to Problem Solutions forum

nurholisah042     2016-06-17 15:20:35

function [ p ] = fib( n ) %FIBBONACCI_A Summary of this function goes here % Detailed explanation for i=1:100000 if i==1; q(i)=0; elseif i==2; q(i)=1; else q(i)=q(i-1)+q(i-2); end if q(i)~=n p=-1; elseif q(i)==1 p=[1 2] return else p=i-1; return end end

Matthew Cole     2016-06-20 15:25:01

Hello nurholisah!

Can you please do three things?

  1. Format the code properly so that it is readable? Put four spaces before each line to turn it into a formatted code block.
  2. What language is this intended to be? It looks like javascript, but I'm not sure.
  3. What is the question? Do you have a test case that your problem doesn't pass? Are you trying to figure out why your code doesn't run or do anything?
Please login and solve 5 problems to be able to post at forum