Functions and Recursions – Arithmetic – Problem #13
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Difficulty: hard
Problem Statement
The choose function C(n,k) defines the number of ways k items can be chosen from a set of n items. Mathematically, it is defined as C(n,k) = n!/(k!(n-k)!). Recursively, it can be defined as C(n,k) = (n* C(n-1,k-1))/k i. Write a recursive function that computes the above mathematical function. Make sure that you cover the base cases. ii. Write a program to test the above function. The program inputs n and k and outputs C(n,k). Assume that n >= k and both n and k are positive integers.