Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Technische Universitt Mnchen Chair for Computation in Engineering

Prof. Dr.rer.nat. Ernst Rank

Introduction to Programming in C++: 9th Assignment


Fibonacci numbers In the 12th century, the famous Italian mathematician Leonardo Fibonacci set up a sequence of integer number which are, since then, known as Fibonacci numbers. They are defined by the following recurrence relation
F n= Fn 1 F n2

with the seed values being F 0=0 and F1 =1 . The first seven numbers of this sequence hence read: F0
0

F1
1

F2
1

F3
2

F4
3

F5
5

F6
8

Assignment: Implement a console application which computes the Fibonacci numbers using recursive function calls. The user shall thereby be able to specify via the console input how many numbers he wants to be computed. The function computing the Fibonacci series shall be implemented in an additional source file (i.e. not main.cpp). The declaration is to placed in a corresponding header file which is then imported via the #include directive. Proceed as follows: a) b) c) d) e) f) g) create the new source and header file implement a recursive function which computes the Fibonacci numbers import the function into your program read the desired number of Fibonacci elements from the console call your recursive function give out the Fibonacci series to the console validate your program

You might also like