Sort:  

Hey sorry, but the code will work if u change 40000 to 400000... Here is the updated one...

len <- 100
fibvals <- numeric(len)

fibvals[1] <- 1
fibvals[2] <- 1
for (i in 3:len)
{
if(fibvals[i-1]+fibvals[i-2] > 400000)
{
break
}
else

fibvals[i] <- fibvals[i-1]+fibvals[i-2]
len = len+1

}

fibvals
sum(fibvals[fibvals %% 2 ==0])

Right now m holidaying at Western coastal area... Won't get chance to run d code n reproduce the answer...

Umm okay, do try formatting it for readability though.

Loading...