Cody

Problem 42781. How many ways to write a number

Given two positive numbers n and k, where n>=k. In how many ways can we write n as sum of k positive numbers. Same numbers but different orders are considered different.

Example

For n=5, k=2 the answer is 4.

 5 = 1 + 4
 5 = 2 + 3
 5 = 3 + 2
 5 = 4 + 1

Solution Stats

22.73% Correct | 77.27% Incorrect
Last Solution submitted on Mar 31, 2019

Problem Comments