Run
public class Main
{
public static void main(String[] args) {
//fill the code
int num = 10;
int total = num * (num-1) / 2; // Combination nC2
System.out.println("For "+ num +" people there will be " +total+" handshakes");
}
}
Output
Maximum number of handshakes for 30 people are 435
public class Main {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int f=scan.nextInt();
int y=f*(f-1);
System.out.println(y/2);
}
}
Please join our discord community for technical problems.
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
int n=5; int r=9;
int f=1;
for(int i=1; i<=n; i++)
{
f=f*i;
}
int n1=n-r;
int f1=1;
for(int j=1; j<=n1; j++)
{
f1=f1*j;
}
int p=f/f1;
System.out.println(p);
}
}