import java.util.stream.DoubleStream; public class TestNumbers { public static void main(String[] args) { System.out.println(); Integer startLength = 11; double[] startData = new double[startLength]; for(int index = 0;index<startLength;index++){ startData[index] = (double) index; } for(int numberOfData = startLength;numberOfData>0;numberOfData--) { int n = 15; double[] data = new double[numberOfData]; for (int index = 0; index < numberOfData; index++) { data[index] = startData[index]; System.out.print(data[index] + " "); } double ruslanacci10; for (int k10 = 0; k10 < n; k10++) { ruslanacci10 = DoubleStream.of(data).sum(); System.arraycopy(data, 1, data, 0, data.length - 1); data[data.length - 1] = ruslanacci10; System.out.print(ruslanacci10 + " "); } System.out.println(); } } } 

work result:
the conclusion should be as it is now

 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 55.0 110.0 219.0 436.0 869.0 1734.0 3463.0 6920.0 13833.0 27658.0 55307.0 110604.0 221153.0 442196.0 884173.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 45.0 90.0 179.0 356.0 709.0 1414.0 2823.0 5640.0 11273.0 22538.0 45067.0 90089.0 180088.0 359997.0 719638.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 36.0 72.0 143.0 284.0 565.0 1126.0 2247.0 4488.0 8969.0 17930.0 35824.0 71576.0 143009.0 285734.0 570903.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 28.0 56.0 111.0 220.0 437.0 870.0 1735.0 3464.0 6921.0 13814.0 27572.0 55033.0 109846.0 219255.0 437640.0 0.0 1.0 2.0 3.0 4.0 5.0 6.0 21.0 42.0 83.0 164.0 325.0 646.0 1287.0 2568.0 5115.0 10188.0 20293.0 40422.0 80519.0 160392.0 319497.0 0.0 1.0 2.0 3.0 4.0 5.0 15.0 30.0 59.0 116.0 229.0 454.0 903.0 1791.0 3552.0 7045.0 13974.0 27719.0 54984.0 109065.0 216339.0 0.0 1.0 2.0 3.0 4.0 10.0 20.0 39.0 76.0 149.0 294.0 578.0 1136.0 2233.0 4390.0 8631.0 16968.0 33358.0 65580.0 128927.0 0.0 1.0 2.0 3.0 6.0 12.0 23.0 44.0 85.0 164.0 316.0 609.0 1174.0 2263.0 4362.0 8408.0 16207.0 31240.0 60217.0 0.0 1.0 2.0 3.0 6.0 11.0 20.0 37.0 68.0 125.0 230.0 423.0 778.0 1431.0 2632.0 4841.0 8904.0 16377.0 0.0 1.0 1.0 2.0 3.0 5.0 8.0 13.0 21.0 34.0 55.0 89.0 144.0 233.0 377.0 610.0 987.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 

the program works in descending order, the output starts from the last to the first. looks like a pyramid upside down from tip to bottom.

for an ascending view, output starts from zero to last

 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 2.0 3.0 5.0 8.0 13.0 21.0 34.0 55.0 89.0 144.0 233.0 377.0 610.0 987.0 0.0 1.0 2.0 3.0 6.0 11.0 20.0 37.0 68.0 125.0 230.0 423.0 778.0 1431.0 2632.0 4841.0 8904.0 16377.0 0.0 1.0 2.0 3.0 6.0 12.0 23.0 44.0 85.0 164.0 316.0 609.0 1174.0 2263.0 4362.0 8408.0 16207.0 31240.0 60217.0 0.0 1.0 2.0 3.0 4.0 10.0 20.0 39.0 76.0 149.0 294.0 578.0 1136.0 2233.0 4390.0 8631.0 16968.0 33358.0 65580.0 128927.0 ....итд 

looks like a pyramid, is built from the tip to the bottom

how to bring this increasing conclusion to a conclusion similar to a decreasing one, in the shape of a pyramid upside down. it turns out he has to shift the line with zeros and write the next line in front of it, etc., from the tip to the bottom up.

    1 answer 1

    Clear. ) The bottom line is that you need to change the first cycle. It should be something like this:

     import java.util.stream.DoubleStream; public class TestNumbers { public static void main(String[] args) { System.out.println(); Integer startLength = 11; double[] startData = new double[startLength]; for(int index = 0;index<startLength;index++){ startData[index] = (double) index; } for(int numberOfData = 1;numberOfData<startLength+1;numberOfData++) { // <-- Изменения тут int n = 15; double[] data = new double[numberOfData]; for (int index = 0; index < numberOfData; index++) { data[index] = startData[index]; System.out.print(data[index] + " "); } double ruslanacci10; for (int k10 = 0; k10 < n; k10++) { ruslanacci10 = DoubleStream.of(data).sum(); System.arraycopy(data, 1, data, 0, data.length - 1); data[data.length - 1] = ruslanacci10; System.out.print(ruslanacci10 + " "); } System.out.println(); } } } 
    • not really, so it just builds a pyramid from zero to last, that is, the order of output is correct, but after System.out.println (); he goes to the next line leaving the first line on the previous one, and it is necessary that he translated the displayed line to a new line, and the following output wrote on the first line. That is, the output order is consistent, but the output should be similar as shown in the original version. - Ruslan Gadzhiev
    • Then for this purpose it is necessary then to use modules that format the data on the screen. And what is the sacral meaning of such a particular behavior? If this is written to a file, the result will still be correct, on the screen too. And where can he not correct? - Axenow
    • In other words, in the item "result of work:" 2 conclusions are shown: the second conclusion which shows how the program works, but the conclusion itself should have the form of the first conclusion - Ruslan Gadzhiev
    • And what is the sacral meaning of such a particular behavior? the direction of the output is not in the standard form, if we present simple numbers, then we have -2 -1 0 1 2, we have 2 directions to which the numbers go. "-" indicates this direction to the left. Between the numbers you get a balance. if our conclusion is compared with the output of simple numbers, then our output corresponds only to 0 1 2. right side, for the balance we need the left side, -2 -1 0. reverse conclusion - Ruslan Gadzhiev