Maximum number of handshakes
It was Raj's first day at school. His teacher Anu asked the students to meet every other student in the class and to introduce themselves. The teacher asked them to do handshakes when they meet each other. If there are N number of students in the class then write a program to print the total number of handshakes made by the students.
Input
The first line is a single integer N
Output
Print the value representing total number of handshakes
Explanation
In the given example there are 5 persons. The first person shakes his hand with 4 persons. The second person then shakes his hand with 3 persons. The third person shakes his hand with 2 persons. The fourth person shakes his hand with 1 person.
From this, the number of handshakes = 4 + 3 + 2 + 1
So, the output should be 10
.
N=int(input())
total = N * (N-1) / 2
print(int(total))
Comments
Leave a comment