employer cover photo
employer logo
employer logo

General Dynamics Mission Systems

Engaged employer

General Dynamics Mission Systems interview question

Write a method to return the nth entry in the Fibonacci sequence.

Interview Answer

Anonymous

5 Jul 2019

int fib(int n) { if(n <= 0) { return 0; } if(n == 1) { return 1; } return fib(n - 1) + fib(n - 2) }