forked from TheRealJishnu/Algorithm_sem_4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcountFibo2.c
More file actions
41 lines (36 loc) · 900 Bytes
/
countFibo2.c
File metadata and controls
41 lines (36 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <stdlib.h>
int count = 0;
int Fibo(int n, int a, int b)
{
if(n == 0){
count += 2;
return a;
}
else if(n == 1){
count +=2;
return b;
}
else{
//count++;
printf("%d\t", a+b); count++;
Fibo(n-1, b, a+b); count++;
//printf("%d\t", k); count++;
}
}
int main()
{
int n, a = 0, b = 1; //count++;
printf("Enter Value of n : "); //count++;
scanf("%d", &n); //count++;
printf("%d\t%d\t", 0, 1); count++;
Fibo(n, a, b);
//printf("%d %d ", a, b); count++;
// count++; // FOR INITIALISATION OF FOR LOOP
// for(int i=0; i<n; i++, count++)
// {
// count++; // FOR LOOP CONDITION CHECK COUNT++
// printf("%d\t", Fibo(i, a, b)); count++;
// }
printf("\n Counter : %d\n", count);
}