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.

Back to Lab Problems
Functions and Recursions/Arithmetic/Problem #13

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #13

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.