M
M
merkulov02019-11-05 23:06:11
Python
merkulov0, 2019-11-05 23:06:11

Python. Get the composition of an integer from N numbers?

Given numbers x and n > 0. You need to get all the ways in which you can express the number x as a sum of n numbers.
Example:
Input:
x = 6 n
= 2
Output:
1 + 5
2 + 4
3 + 2

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2019-11-05
@dimonchik2013

here

G
Griboks, 2019-11-06
@Griboks

There are infinitely many such ways, so the problem has no solution. It seems that the teacher decided to play a joke on you and slipped a rotten problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question