Rackspace Interview Question: Can you write the code to gen... | Glassdoor

Interview Question

Linux Systems Administrator Interview San Antonio, TX

Can you write the code to generate the Fibonacci sequence?


Interview Answer

4 Answers



$p = 0;
$n = 1;
$t = 0;

for ($i = 0; $i < 50; $i++) {
printf "%d ", $p;
$t = $p + $n;
$p = $n; $n = $t;

Dan on Mar 15, 2012


Thank you so much for posting this. I am going to have interview with Rack space for
Linux system administrator Position.

Can you please provide some question that has been asked by them so it will help me prepare for the interview.


Vishal on Mar 28, 2012

My impulse is to use a temporary value holder as well, but I've seen a more elegant solution (in python). It's so pretty...

l = 0
n = 1
print l
for i in range(100):
    print n
    n = n + l
    l = n - l

Jason on Sep 3, 2012

the best way is to use recursive call..
but if i was asked..i will probably end up with this
def fab():
    x = 0
    y = 1
    while y < 100:
        print x
        print y
        x += y
        y += x


cxf on Nov 16, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.