Dec 232017
 
Turbo Pascal Demo of Fib Number Calculation.
File FIBONAC.ZIP from The Programmer’s Corner in
Category Pascal Source Code
Turbo Pascal Demo of Fib Number Calculation.
File Name File Size Zip Size Zip Type
FIBONAC.COM 11811 8810 deflated
FIBONAC.DOC 3127 665 deflated
FIBONAC.PAS 659 273 deflated

Download File FIBONAC.ZIP Here

Contents of the FIBONAC.DOC file


**********************************************************************
You should have the following files in the arc file :


Fibonac.pas - Fibonacci source.

Fibonac.com - In case you do not have turbo pascal you can still
work with the idea of Fibonacci sequence.

Fibonac.doc - Fibonacci introduction.
**********************************************************************


This program was written to turn our attention
to the idea of fibonacci sequences. This program illustrates
that a recursive routine may call itself a number of times
with different arguments. In fact, as long as a recursive
routine uses only local variables, the programmer can use
the routine just as he uses any other and assume that it
performs its function and produces the desired value. You
need not worry about the underlying stacking mechanism.


RECURSION stack operation for fibonacci function :

N X Y Pass

6 * *
---------------- 1

5 * *
6 * *
---------------- 2

4 * *
5 * *
6 * *
---------------- 3

3 * *
4 * *
5 * *
6 * *
---------------- 4

2 * *
3 * *
4 * *
5 * *
6 * *
---------------- 5

1 * *
2 * *
3 * *
4 * *
5 * *
6 * *
---------------- 6

2 1 *
3 * *
4 * *
5 * *
6 * *
---------------- 7

0 * *
2 1 *
3 * *
4 * *
5 * *
6 * *
---------------- 8

0 * *
2 1 *
3 * *
4 * *
5 * *
6 * *
---------------- 9

2 1 0
3 * *
4 * *
5 * *
6 * *
---------------- 10

3 1 *
4 * *
5 * *
6 * *
---------------- 11

1 * *
3 1 *
4 * *
5 * *
6 * *
---------------- 12

3 1 1
4 * *
5 * *
6 * *
---------------- 13

4 2 *
5 * *
6 * *
---------------- 14

2 * *
4 2 *
5 * *
6 * *
---------------- 15

1 * *
2 * *
4 2 *
5 * *
6 * *
---------------- 16

0 * *
2 1 *
4 2 *
5 * *
6 * *
---------------- 17

2 1 0
4 2 *
5 * *
6 * *
---------------- 18

4 2 1
5 * *
6 * *
---------------- 19

5 3 *
6 * *
---------------- 20

3 * *
5 3 *
6 * *
---------------- 21

The rest of the stack operation is left for you
to finish as an excercise.



 December 23, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)