this piece of code will print factorial of all number ranging from 1 to n. Complexity is O(n).

```
#include <stdio.h>
int fact(int n)
{
static int count=1;
if(n==0)
return 1;
else
n=n*fact(n-1);
printf("factorial of %d=%d\n",count++,n);
return n;
}
int main(void) {
int n;
printf("enter the number:\n");
scanf("%d",&n);
fact(n);
return 0;
}
```