Amazon.com

  www.amazon.com
Work in HR? Unlock Free Profile

Amazon.com Intern Software Development Engineer Interview Question

"Write an iterative Fibonacci function"
Add Tags [?]
Answer

Part of a Intern Software Development Engineer Interview Review - one of 4,771 Amazon.com Interview Reviews

Answers & Comments

0
of 0
votes

int a = 0;
int b = 1;
int numberOfFibs = 0;
fibonacci(int a, int b, int c) {
while ( count != numberOfFibs) {
  c = a + b;
  b = c;
  a = b;
  numberOfFibs++;
 }
}

- Anonymous on Jan 12, 2014
0
of 0
votes

int a = 0;
int b = 1;
int numberOfFibs = 0;
int count = 5; //for 0 1 1 2 3 5 8
void fibonacci(int a, int b, int c) {
while ( count > numberOfFibs) {
  c = a + b;
  b = c;
  a = b;
  numberOfFibs++;
 }
}

- Anonymous on Jan 12, 2014

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

Tags are like keywords that help categorize interview questions that have something in common.