Starting from:
$30

$24

Homework 10: Fibonacci number Solution




Instruction




Submit your answer to this question via PC^2 under your account by the posted due time. No late submissions will be accepted. Note that homework is opened-book, but no outside assistance is permitted.




Problem




The Fibonacci sequence is the series of numbers, e.g., 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ..., where a number is found by adding up the two numbers before it.




Write a program that computes the Fibonacci numbers of a non-negative

integer
n , denoted by F (n) as follows:
F (n)=
0, if n=0
1, if n=1


F (n −1)+ F (n− 2),if n ≥ 2
Warning: Input number could be pretty big so design a faster algorithm.







Sample input




10




20







Sample output




55




6765

More products