S
S
SankaSanka2019-06-14 16:02:54
Java
SankaSanka, 2019-06-14 16:02:54

How to split a segment into unequal parts?

There is a Main Segment of the number line with coordinates min and max.
It needs to be divided into segments (the number is set), each segment will have an initial coordinate and an ending one.
then from the numbers that fell into the segments we will calculate n prime numbers. But that is another story. :)
The essence of the question: you need to divide the Main Segment into pieces in such a tricky way that the calculation time on each small piece is the same. And it depends on the size of the numbers that are being processed.
Accordingly, each next piece should be less than the previous one. (how much?)
Is there some simple algorithm or formula for how to do this?
I could just divide into equal parts. There is a ready array of coordinates. You can take these coordinates as a start and somehow shift (?).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2019-06-14
@SankaSanka

If you check the simplicity of a number by sequential enumeration up to sqrt (n), then the “complexity” can be considered proportional to the square root of N. And you need to find sections with the same area under a parabola rotated by 90 ° above each of the sections.
Integrals, derivatives - remember)
Since the problem is discrete , only integers are considered, the solution will always be inaccurate - the “loads” of adjacent segments will somehow differ. And there are extreme cases without a solution. For example, when the segment from 5 to 6 needs to be divided into 1000 parts)
When checking the number, it is enough to sort out only the odd ones (checking the evenness of N at the beginning) and not exceed the square root of N.
The integral of the square root is 2/3 * sqrt(x^3)
Calculate the area under the graph from Min to Max.
Beat this area into N equal pieces. And count the x values ​​corresponding to such a division.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question