Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Finds ALL runs of X consecutive positive integers that sum to a given number for all X in a specified range. * The range bounds

 Finds ALL runs of X consecutive positive integers that sum to a given number for all X in a specified range.

* The range bounds are inclusive.

*

* Examples:

* runs(9,2,3) -> [ [4,5], [2,3,4] ] // two runs found

* runs(9,1,1) -> [ [9] ] // one run found

* runs(9,4,8) -> [ ] // no runs found!

* runs(125,1,8) -> [ [125], [62,63], [23,24,25,26,27]] // 3 runs!

*

* number must be a positive integer

* start is lower bound for the range (of consecutive numbers in the sum). It is a positive integer.

* end is the upper bound for the range (of consecutive numbers in the sum). It is a positive

* integer that is not smaller than start.

* return an array of arrays. Each inner array is a sequence of consecutive positive

* integers that sum to the input number. The ordering inside the arrays is that

* is the natural ordering (increasing order by value), and the ordering of the inside arrays

* is by increasing length.

*/

public static int[][] runs(int number, int start, int end){

return null;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Discrete Mathematics and Its Applications

Authors: Kenneth H. Rosen

7th edition

0073383090, 978-0073383095

More Books

Students also viewed these Programming questions