[ create a new paste ] login | about

Link: http://codepad.org/jCVM4Ykm    [ raw code | output | fork ]

C, pasted on Apr 24:
#include<stdio.h>
#include<conio.h>
#include<math.h>


float deQuy(int n)
{
	if(n == 1)
		return 1;
	return sqrt(n + deQuy(n - 1));
}


float khuDeQuy(int n)
{
	float S = 1;
	for(int i = 2; i <= n; i++)
	{
		S = sqrt(i + S);
	}
	return S;
}
int main()
{
	int n;
	printf("\nNhap n: "); scanf("%d", &n);

	printf("\nDe quy %d = %f", n, deQuy(n));
	//printf("\nDe quy duoi %d = %f", n, deQuyDuoi(n));
	printf("\nKhu de quy %d = %f", n,khuDeQuy(n));

	getch();
	return 0;
}


Output:
1
2
3
Line 17: error: conio.h: No such file or directory
In function 'khuDeQuy':
Line 17: error: 'for' loop initial declaration used outside C99 mode


Create a new paste based on this one


Comments: