Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int main()
- {int pdt,rem=0,count,no;
- long int x=0;
- long int res[60000];
- long register int i;
- printf("enter the number whose factorial has to be calculated");
- scanf("%d",&no);
- for(i=0;i<60000;i++)
- res[i]=0;
- res[59999]=1;
- i=i-1;
- for(count=2;count<=no;count++)
- {while(i>0)
- {pdt=res[i]*count+rem;
- rem=0;
- if(pdt>9)
- {res[i]=pdt%10;
- rem=pdt/10;
- }
- else
- {res[i]=pdt;
- }
- i--;
- }
- rem=0;
- pdt=0;
- i=59999;
- }
- printf("factorial is\n");
- for(i=0;i<=59999;i++)
- {if(res[i]!=0||count==1)
- {printf("%d",res[i]);
- count=1;
- x++;
- }}
- printf("%d",x);
- return(0);}
Add Comment
Please, Sign In to add comment