You are here: Home » Programming & Computer » PHP » Fibonacci with PHP

Fibonacci with PHP


Many times I went for an interview, the interviewer will give me test paper and this questions comes out frequently. Too bad, each time my brain is empty and can not provide them with correct answer. I can’t tell you the reason why, maybe because too tension or wish to get the position placement offered to me badly until make things even worst than as I expected.

What is Fibonacci Number?
By definition, the first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two. Some sources omit the initial 0, instead beginning the sequence with two 1s.

Okay, here are the codes. It maybe not be the best code as long as the output is correct (Ha~ I’m sorry to give you an impression of pretty looks but with an empty heart).

PHP Code:
Figure1: Fibonnaci


0 1 1 2 3 5 8 13 21 34 55 89



Leave a Reply

Your email address will not be published. Required fields are marked *