Advertisement
a53

Factorial1

a53
Feb 6th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. typedef unsigned short int NrMare[10010];
  4. NrMare y;
  5.  
  6. void AtribMic(NrMare x, int n)
  7. {
  8. // x=n;
  9. x[0]=0;
  10. if(n==0)
  11. x[(x[0]=1)]=0;
  12. else
  13. for(;n;n/=10)
  14. x[++x[0]]=n%10;
  15. }
  16.  
  17. void ProdusMic(NrMare x, int n)
  18. //x <- x*n
  19. {
  20. int i,t=0;
  21. for(i=1;i<=x[0];i++,t/=10)
  22. {
  23. t+=x[i]*n;
  24. x[i]=t%10;
  25. }
  26. for(;t;t/=10)
  27. x[++x[0]]=t%10;
  28. }
  29.  
  30. void AfisezMare(NrMare x)
  31. // afisez x
  32. {
  33. int i;
  34. for(i=x[0];i>=1;i--)
  35. cout<<x[i];
  36. }
  37.  
  38. int n;
  39. int main()
  40. {
  41. cin>>n;
  42. AtribMic(y,1);
  43. for(int i=1;i<=n;i++)
  44. ProdusMic(y,i); // y=y*i;
  45. AfisezMare(y);
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement