#include <stdio.h>

int C (int);

main () {

	int N, Ans;

	printf ("This program computes the exact value of Cn in formula 2 on page 77 in the book Algorithms in C by Sedgewick.\n");
	printf ("Please give me a value for N. ");
	scanf ("%d", &N);
	Ans = C (N);
	printf ("The exact value is %d.\n", N);

	exit();
}

int C (int N) {
	
	int x = 0, y;

	printf("%d\n", N);

	if (N==1)
		return(0);

	if (N % 2 == 1)
		x = ((N+1) / 2);
	else
		x = N/2;

	y = C(x) + y + 1;

	return (y);
}

/* I know that I need to print out how many times it runs through this recurrsive loop.  I can not get this program
   to do it.  I am sure I am over looking something small once again.
*/

