diff --git a/C/Permutation and Combination of a number b/C/Permutation and Combination of a number new file mode 100644 index 0000000..6a85474 --- /dev/null +++ b/C/Permutation and Combination of a number @@ -0,0 +1,25 @@ +import java.util.Scanner; +public class nprandncr { +//calculating a factorial of a number +public static int fact(int num) +{ +int fact=1, i; +for(i=1; i<=num; i++) +{ +fact = fact*i; +} +return fact; +} +public static void main(String args[]) +{ +int n, r; +Scanner scan = new Scanner(System.in); +System.out.print("Enter Value of n : "); +n = scan.nextInt(); +System.out.print("Enter Value of r : "); +r = scan.nextInt(); +// NCR and NPR of a number +System.out.print("NCR = " +(fact(n)/(fact(n-r)*fact(r)))); +System.out.print("nNPR = " +(fact(n)/(fact(n-r)))); +} +}