Interview Question

Linux Systems Administrator Interview San Antonio, TX

Can you write the code to generate the Fibonacci sequence?

Answer

Interview Answer

4 Answers

0

#!/usr/bin/perl

$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
0

HI,

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.

Thanks,
Vishal

Vishal on Mar 28, 2012
0

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
0

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

fab()

cxf on Nov 16, 2013

Add Answers or Comments

To comment on this Question, Sign In with Facebook or Sign Up