I'm wanting to know the name of a mathematical method to find out what is the most profitable range of certain values

46 Views Asked by At

To be able to find the most profitable range, I add the lowest value I want to the highest value I want, with that I create a table like this example:

enter image description here

As you can see, the most profitable range in this example is when sum the results from 4 to 10.

I'm trying to figure out what the mathematical name for this type of search is, because I'm looking for methods to get to this result without having to do it one by one, but for that I need to know the name of what I'm looking for.

Maybe I couldn't be clear, but for example:

if John has 3 eggs and can make 10 pancakes, how many pancakes can Mary make if she has 5 eggs?

To reach this result we use the rule of three.

And that's what I'm looking for, what's name it called?

Note: The pancake example was just to explain what I was looking for, which would be the name mathematical rule of three.

1

There are 1 best solutions below

1
On BEST ANSWER

The problem "given $a_0,a_1,\dots,a_n\in \mathbb{Z}$, find $0\le j<k\le n$ such that $\sum_{i=j}^k a_i$ is maximised" is called the "maximum subarray problem" or "maximum consecutive subsequence sum" problem or something similar.

Your naive approach requires $(n+1)^2/2\in O(n^2)$ calculations, which is not too bad.

Kadane's algorithm is $O(n)$: see Wikipedia or GeeksforGeeks.