C_Algorithms
2.0.0
Documentation
Loading...
Searching...
No Matches
misc
src
dynamicFib.c
Go to the documentation of this file.
1
#include <stdio.h>
2
3
#include "
dynamicFib.h
"
4
12
long
DynFib
(
int
n)
13
{
14
if
(n <= 2)
15
return
1;
16
long
array[n - 1];
17
array[0] = 1;
// Basevalue for fibonacci 1 = 1
18
array[1] = 1;
// Basevalue for fibonacci 2 = 1
19
20
// Safe value from the n th fibonacci number in array[n - 1]
21
for
(
long
i = 2; i < n; i++)
22
array[i] = array[i - 1] + array[i - 2];
23
return
array[n - 1];
// Return the value
24
}
25
31
void
DynamicFib
(
int
number)
32
{
33
printf(
"%ld\n"
,
DynFib
(number));
34
}
DynFib
long DynFib(int n)
DynFib is a function that is calculating the fibonacci number dynamic. It's a lot faster as the recur...
Definition
dynamicFib.c:12
DynamicFib
void DynamicFib(int number)
Prints the return value of the called function RecFib.
Definition
dynamicFib.c:31
dynamicFib.h
Generated by
1.10.0