Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
naveen kunuru

# can any one help an interview scenario

hello ,i need a code whose o/p will be {1,1,2,3,5,8,13,21,34,55}
loop should rotate 10 times
this scenario add two num every time when loop rotates;
plzzzzzzzz thanks
Best Answer chosen by naveen kunuru
Ramesh Kosalairaman
```Integer loopCount = 10;
list<Integer> FibonacciList = new list<Integer>();
Integer fibo1=0, fibo2=1, fibonacci=1;
for(Integer i= 0; i< loopCount; i++){
fibonacci = fibo1 + fibo2;
fibo1 = fibo2;
fibo2 = fibonacci;
}
system.debug('Fibonacci number'+FibonacciList);```

naveen kunuru
hey i wrote all this in anonymous class if i able to show in log files thats will be grand
naveen kunuru
basic code what is known is
integer r=1;

interger j=1;

integer l=r+j;
for(integer i=0,i<10,i++){
list<integer> k=new list<integer>();

}
system.debug(''+k);
Ramesh Kosalairaman
```Integer loopCount = 10;
list<Integer> FibonacciList = new list<Integer>();
Integer fibo1=0, fibo2=1, fibonacci=1;