Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. printf("%d/%d\n",a[i],b[i]);/******************************************************************************
  2. ]);
  3. Online C Compiler.
  4. Code, Compile, Run and Debug C program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11.  
  12. int factorial (int n);
  13. int per (int n);
  14. int main()
  15. {
  16. int i,j,a[5000],b[5000],t,sum=1;
  17. t=3;
  18. int n[]={2,3,4};
  19.  
  20. for (i=0;i<t;i++)
  21. {
  22. b[i]=factorial(n[i]);
  23. sum=0;
  24. for (j=2;j<n[i];j++)
  25. {
  26. sum=sum+per(j);
  27. }
  28.  
  29. a[i]=per(n[i])-sum;
  30. printf("%d/%d\n",a[i],b[i]);
  31. }
  32. return 0;
  33. }
  34.  
  35. int factorial (int n)
  36. {
  37. int factorial,i,sum=1;
  38.  
  39. for(i=1;i<n+1;i++)
  40. {
  41. sum=sum*i;
  42. }
  43. return sum;
  44. }
  45.  
  46. int per (int n)
  47. {
  48. int per;
  49. per=factorial(n)/(factorial(n-2));
  50. return per;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement