e.g n! = n.(n - 1).(n - 2).....1
/*
title: Factorial
coder: aeriqusyairi]
date: dec30 2011
*/
#include<stdio.h>
#include<stdlib.h>
int main(){
int a=0,b=0,factorial=1;
printf("Input a nonnegative integer: ");
scanf("%d", &a);
while(a != 0){
factorial *= a;
a--;
}
printf("The factorial is %d.\n", factorial);
system("pause");
return 0;
}
No comments:
Post a Comment