Sunday, October 30, 2011

Find permutation .

Write a program for Find permutation.

# include<stdio.h>
int fact(int);
int main()
{
int n,r,P;
scanf("%d %d",&n,&r);
if(n>=r)
    {
    P=fact(n)/fact(n-r);
    printf("%dP%d=%d",n,r,P);
    return 0;
    }
}
int fact(int n)
    {
        int i,f=1;
    for(i=1;i<=n;i++)
    f=f*i;
        return (f);
    }

From: Me

No comments:

Post a Comment

Comment of this content!