If the components being searched have non-uniform access memory storage (i. e., the time needed to access a storage location vary depending on the location accessed), the Fibonacci search may have the advantage over binary search in slightly reduce the average time needed to access a storage location. On average, this leads to about 4 % more comparisons to be executed, but it has the advantage that one only needs addition and subtraction to calculate the index of the accessed array components, while classical binary search needs bit-shift, division or multiplication, operations that were less common at the time Fibonacci search was first published.

If the item is less than entry Fk−1, discard the components from positions Fk−1 + 1 to n.(throughout the algorithm, p and q will be consecutive Fibonacci numbers)

```
% fib: returns the n-th fibonacci number
% indexing begings by 0
% assumes: number is positive
function y = fib(n)
assert(n >= 0,'n must be >= 0')
n0 = 1; % init values for the fibonacci sequence
n1 = 2;
tmp = 0;
for i = 1 : 1 : n
tmp = n1;
n1 = n1 + n0;
n0 = tmp;
endfor
y = n0;
endfunction
```