[ create a new paste ] login | about

Link: http://codepad.org/ZSeY1iFc    [ raw code | output | fork | 1 comment ]

C, pasted on Aug 17:
#include<stdio.h>
#include<conio.h>

int main()
{
	int i, n;
	long P;
	i = 1;
	P = 1;
	do
	{
		printf("\nNhap n: ");
		scanf("%d", &n);
		if(n < 1)
		{
			printf("\nN phai lon hon hoac bang 1. Xin nhap lai !");
		}
	}while(n < 1);

	while(i < n)
	{
		P = P * i;
		i++;
	}
	printf("\nTich 1x2x....x%d la: %ld", i, P);

	getch();
	return 0;
}


Output:
1
Line 17: error: conio.h: No such file or directory


Create a new paste based on this one


Comments:
posted by MinhNhat on Feb 1
#include <iostream>
using namespace std;

int main()
{
int n;
cin>>n;
int p=1;
for(int i=1;i<=n;i++)
{
p=p*i;
}
cout<<p;

return 0;
/*HuynhMinhNhat*/
}
reply