-
-
Save programmingfaster0226/7476dd1ac30d8a92f8240c93201837fa to your computer and use it in GitHub Desktop.
programmingfaster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<conio.h> | |
long factorial(int); | |
int main() | |
{ | |
int number,ncr,npr; | |
int r; | |
long fact = 1; | |
factorial(number); | |
printf("Enter a number(n) to calculate it's factorial and r such n>r\n"); | |
scanf("%d %d",&number,&r); | |
printf("%d! = %ld\n", number, factorial(number)); | |
npr=factorial(number)/factorial(number-r); | |
ncr=factorial(number)/(r*factorial(number-r)); | |
printf("ncr=%d\n",ncr); | |
printf("npr=%d",npr); | |
return 0; | |
} | |
long factorial(int n) | |
{ | |
int c; | |
long result = 1; | |
for( c = 1 ; c <= n ; c++ ) | |
result = result*c; | |
return ( result ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment