my code shows timeout error help
#include<stdio.h>
int fact(int n);
int main()
{
int t=0, num,milgaya;
printf(“enter test cases”);
scanf("%d",&t);
while(t!=0)
{printf(“ener number “);
scanf(”%d”,&num);
printf(“of %d “,num);
milgaya = fact(num);
printf(”%d”,milgaya);
t–;
}
return 0;
}
int fact(int n)
{
int i=1,ans=0;
if (n!=1)
while (i!=n)
{
ans = n*i;
}
else
ans = 1;
return (ans);
}