Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- printf("%d/%d\n",a[i],b[i]);/******************************************************************************
- ]);
- Online C Compiler.
- Code, Compile, Run and Debug C program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- int factorial (int n);
- int per (int n);
- int main()
- {
- int i,j,a[5000],b[5000],t,sum=1;
- t=3;
- int n[]={2,3,4};
- for (i=0;i<t;i++)
- {
- b[i]=factorial(n[i]);
- sum=0;
- for (j=2;j<n[i];j++)
- {
- sum=sum+per(j);
- }
- a[i]=per(n[i])-sum;
- printf("%d/%d\n",a[i],b[i]);
- }
- return 0;
- }
- int factorial (int n)
- {
- int factorial,i,sum=1;
- for(i=1;i<n+1;i++)
- {
- sum=sum*i;
- }
- return sum;
- }
- int per (int n)
- {
- int per;
- per=factorial(n)/(factorial(n-2));
- return per;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement