The coding Challenges @ Dcoder

in #programming11 months ago

Problem: There are n participants appearing for one on one coding challenge.Each participant plays twice (challenges) with each of his opponents.You need to compute the total number of challenges.
Input: First line contains an integer n, represent number of participants.
Output: Print the total number of challenges.
Constraints: 1≤n≤100
Sample Input: 16
Sample Output:
240

from operator import mul
from functools import reduce
n= int(input())
if n > 2:
  print(reduce(mul, range(1, n+1)) // reduce(mul, range(1, n-1)))
else:
  print(n // 2)