예제 #1
0
파일: fib.c 프로젝트: Vmoney23/PANDA1
int fibRec(int n)
{
	if(n==0||n==1)
	{
	  	return n;
	}

	return fibRec(n-1)+fibRec(n-2);

}
예제 #2
0
파일: 6Fibonacci.c 프로젝트: f2008700/BITS
int fibRec(int n)

{

	if(n<0)

	{

		printf("N value should be Greater than or Equal to ZERO\n");

		return 0;

	}

	else if((n==0)||(n==1))

		return n;

	else

		return (fibRec(n-2)+fibRec(n-1));

}
예제 #3
0
파일: 6Fibonacci.c 프로젝트: f2008700/BITS
int main()

{

	int N;

	printf("Enter N\n");

	scanf("%d",&N);

	printf("Fibonacci (with Iteration) of %d is %d\n",N,fibIte(N));

	printf("Fibonacci (with Recursion) of %d is %d\n",N,fibRec(N));

	return 0;

}
예제 #4
0
파일: fib.c 프로젝트: Vmoney23/PANDA1
int main()
{

	clock_t begin,end;
	// FILE *fp;
	// fp = fopen("list.txt", "w");

  	for(int n = 1; n < 46; n++){
  	
  		double time_spent=0;

  		begin = clock();
  		fibRec(n);
  		end = clock();

  		time_spent += (double)(end - begin) / CLOCKS_PER_SEC;
  		printf("%i %f\n",n,time_spent);
  	}

  	return 0;
}
예제 #5
0
int fibRec(int n){
    if(n < 2)
        return n;
    else
        return fibRec(n-1) + fibRec(n-2);
}