Factorials in C

Factorials in C


Hope this helps.

1

9 MONTHS LATER

cpsoni

Jan '16

#include<stdio.h>
int main()
{
int t,i,n[100],f=1,j=1;
for(i=0;i<t;i++)
{
scanf("%d",&n[i]);
while(j<=n[i])
{
f=f*j;
j++;
}
printf("%d\n",f);
}
return 0;
}
can someone tell me whats wrong with the code?

 

nicesantosh

Jan '16

 

HackerEarth

 

Small Factorials | Ternary Search & Algorithms Practice Problems 35

You are asked to calculate factorials of some small positive integers. Input An integer T, denoting the number of testcases, followed by T lines, each containing a single integer N. ...


Read the above editorial and try to understand.

 

 

1 MONTH LATER

soclutch

Feb '16

Okay Thanks