Answer to Question #234364 in Python for umesh

Question #234364

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

.



1
Expert's answer
2021-09-07T23:22:03-0400
N=int(input())


total = N * (N-1) / 2


print(int(total))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS