Guest User

Untitled

a guest
Dec 9th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int main()
  4. {int pdt,rem=0,count,no;
  5. long int x=0;
  6. long int res[60000];
  7. long register int i;
  8. printf("enter the number whose factorial has to be calculated");
  9. scanf("%d",&no);
  10. for(i=0;i<60000;i++)
  11. res[i]=0;
  12. res[59999]=1;
  13. i=i-1;
  14. for(count=2;count<=no;count++)
  15. {while(i>0)
  16. {pdt=res[i]*count+rem;
  17. rem=0;
  18. if(pdt>9)
  19. {res[i]=pdt%10;
  20. rem=pdt/10;
  21. }
  22. else
  23. {res[i]=pdt;
  24. }
  25. i--;
  26. }
  27. rem=0;
  28. pdt=0;
  29. i=59999;
  30. }
  31. printf("factorial is\n");
  32. for(i=0;i<=59999;i++)
  33. {if(res[i]!=0||count==1)
  34. {printf("%d",res[i]);
  35. count=1;
  36. x++;
  37. }}
  38. printf("%d",x);
  39. return(0);}
Add Comment
Please, Sign In to add comment