Skip to content

Commit

Permalink
Permutation in java
Browse files Browse the repository at this point in the history
  • Loading branch information
suhanigupta23 authored Feb 1, 2024
1 parent 43efda3 commit 0cf714d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions permutation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import java.util.*;
public class Program
{
public static void main(String[] args)
{
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();
int r=scn.nextInt();

int nfact=1;
for(int i=1;i<=n;i++)
{
nfact*=i;
}
int nmrfact=1;
for(int i=1;i<=n-r;i++)
{
nmrfact*=i;
}
int npr=nfact/nmrfact;
System.out.println(n+"P"+r+" = "+npr);
}
}

0 comments on commit 0cf714d

Please sign in to comment.