@@ -8,20 +8,18 @@ public final class MathUtil {
88
99 private MathUtil () {}
1010
11- /**
12- * Applies the sums of a function over a range of values.
13- * Example:
14- * <pre>
15- * summation(1, 5, i -> i * i) // returns 55 (1^2 + 2^2 + 3^2 + 4^2 + 5^2)
16- * summation(1, 5, i -> i) // returns 15 (1 + 2 + 3 + 4 + 5)
17- * summation(0, 0, i -> i) // returns 0 (0)
18- * </pre>
19- * @param min the minimum value to start the summation. Must be smaller or equal to max.
20- * @param max the maximum value to end the summation. Must be greater or equal to min.
21- * @param summationFunction the function to apply to each value in the range before summing them up.
22- * @return the summation of the function applied to each value in the range
23- * @throws IllegalArgumentException if min is greater than max
24- */
11+ /// Applies the sums of a function over a range of values.
12+ /// Example:
13+ /// ```
14+ /// summation(1, 5, i -> i * i) // returns 55 (1^2 + 2^2 + 3^2 + 4^2 + 5^2)
15+ /// summation(1, 5, i -> i) // returns 15 (1 + 2 + 3 + 4 + 5)
16+ /// summation(0, 0, i -> i) // returns 0 (0)
17+ /// ```
18+ /// @param min the minimum value to start the summation. Must be smaller or equal to max.
19+ /// @param max the maximum value to end the summation. Must be greater or equal to min.
20+ /// @param summationFunction the function to apply to each value in the range before summing them up.
21+ /// @return the summation of the function applied to each value in the range
22+ /// @throws IllegalArgumentException if min is greater than max
2523 public static int summation (int min , int max , IntFunction <Integer > summationFunction ) {
2624
2725 if (min > max ) {
@@ -37,20 +35,18 @@ public static int summation(int min, int max, IntFunction<Integer> summationFunc
3735 return sum ;
3836 }
3937
40- /**
41- * Applies the sums of a function over a range of values.
42- * Example:
43- * <pre>
44- * summation(1, 5, i -> i * i) // returns 55 (1^2 + 2^2 + 3^2 + 4^2 + 5^2)
45- * summation(1, 5, i -> i) // returns 15 (1 + 2 + 3 + 4 + 5)
46- * summation(0, 0, i -> i) // returns 0 (0)
47- * </pre>
48- * @param min the minimum value to start the summation. Must be smaller or equal to max.
49- * @param max the maximum value to end the summation. Must be greater or equal to min.
50- * @param summationFunction the function to apply to each value in the range before summing them up.
51- * @return the summation of the function applied to each value in the range
52- * @throws IllegalArgumentException if min is greater than max
53- */
38+ /// Applies the sums of a function over a range of values.
39+ /// Example:
40+ /// ```
41+ /// summation(1, 5, i -> i * i) // returns 55 (1^2 + 2^2 + 3^2 + 4^2 + 5^2)
42+ /// summation(1, 5, i -> i) // returns 15 (1 + 2 + 3 + 4 + 5)
43+ /// summation(0, 0, i -> i) // returns 0 (0)
44+ /// ```
45+ /// @param min the minimum value to start the summation. Must be smaller or equal to max.
46+ /// @param max the maximum value to end the summation. Must be greater or equal to min.
47+ /// @param summationFunction the function to apply to each value in the range before summing them up.
48+ /// @return the summation of the function applied to each value in the range
49+ /// @throws IllegalArgumentException if min is greater than max
5450 public static long summation (long min , long max , LongFunction <Long > summationFunction ) {
5551
5652 if (min > max ) {
@@ -66,20 +62,18 @@ public static long summation(long min, long max, LongFunction<Long> summationFun
6662 return sum ;
6763 }
6864
69- /**
70- * Applies the sums of a function over a range of values.
71- * Example:
72- * <pre>
73- * summation(1, 5, i -> i * i) // returns 55 (1^2 + 2^2 + 3^2 + 4^2 + 5^2)
74- * summation(1, 5, i -> i) // returns 15 (1 + 2 + 3 + 4 + 5)
75- * summation(0, 0, i -> i) // returns 0 (0)
76- * </pre>
77- * @param min the minimum value to start the summation. Must be smaller or equal to max.
78- * @param max the maximum value to end the summation. Must be greater or equal to min.
79- * @param summationFunction the function to apply to each value in the range before summing them up.
80- * @return the summation of the function applied to each value in the range
81- * @throws IllegalArgumentException if min is greater than max
82- */
65+ /// Applies the sums of a function over a range of values.
66+ /// Example:
67+ /// ```
68+ /// summation(1, 5, i -> i * i) // returns 55 (1^2 + 2^2 + 3^2 + 4^2 + 5^2)
69+ /// summation(1, 5, i -> i) // returns 15 (1 + 2 + 3 + 4 + 5)
70+ /// summation(0, 0, i -> i) // returns 0 (0)
71+ /// ```
72+ /// @param min the minimum value to start the summation. Must be smaller or equal to max.
73+ /// @param max the maximum value to end the summation. Must be greater or equal to min.
74+ /// @param summationFunction the function to apply to each value in the range before summing them up.
75+ /// @return the summation of the function applied to each value in the range
76+ /// @throws IllegalArgumentException if min is greater than max
8377 public static double summation (double min , double max , DoubleFunction <Double > summationFunction ) {
8478
8579 if (min > max ) {
@@ -95,20 +89,18 @@ public static double summation(double min, double max, DoubleFunction<Double> su
9589 return sum ;
9690 }
9791
98- /**
99- * Applies the product of a function over a range of values.
100- * Example:
101- * <pre>
102- * product(1, 5, i -> i * i) // returns 14400 (1^2 * 2^2 * 3^2 * 4^2 * 5^2)
103- * product(1, 5, i -> i) // returns 120 (1 * 2 * 3 * 4 * 5)
104- * product(0, 0, i -> i) // returns 0 (0)
105- * </pre>
106- * @param min the minimum value to start the summation. Must be smaller or equal to max.
107- * @param max the maximum value to end the summation. Must be greater or equal to min.
108- * @param productFunction the function to apply to each value in the range before summing them up.
109- * @return the summation of the function applied to each value in the range
110- * @throws IllegalArgumentException if min is greater than max
111- */
92+ /// Applies the product of a function over a range of values.
93+ /// Example:
94+ /// ```
95+ /// product(1, 5, i -> i * i) // returns 14400 (1^2 * 2^2 * 3^2 * 4^2 * 5^2)
96+ /// product(1, 5, i -> i) // returns 120 (1 * 2 * 3 * 4 * 5)
97+ /// product(0, 0, i -> i) // returns 0 (0)
98+ /// ```
99+ /// @param min the minimum value to start the summation. Must be smaller or equal to max.
100+ /// @param max the maximum value to end the summation. Must be greater or equal to min.
101+ /// @param productFunction the function to apply to each value in the range before summing them up.
102+ /// @return the summation of the function applied to each value in the range
103+ /// @throws IllegalArgumentException if min is greater than max
112104 public static int product (int min , int max , IntFunction <Integer > productFunction ) {
113105
114106 if (min > max ) {
@@ -124,20 +116,18 @@ public static int product(int min, int max, IntFunction<Integer> productFunction
124116 return product ;
125117 }
126118
127- /**
128- * Applies the product of a function over a range of values.
129- * Example:
130- * <pre>
131- * product(1, 5, i -> i * i) // returns 14400 (1^2 * 2^2 * 3^2 * 4^2 * 5^2)
132- * product(1, 5, i -> i) // returns 120 (1 * 2 * 3 * 4 * 5)
133- * product(0, 0, i -> i) // returns 0 (0)
134- * </pre>
135- * @param min the minimum value to start the summation. Must be smaller or equal to max.
136- * @param max the maximum value to end the summation. Must be greater or equal to min.
137- * @param productFunction the function to apply to each value in the range before summing them up.
138- * @return the summation of the function applied to each value in the range
139- * @throws IllegalArgumentException if min is greater than max
140- */
119+ /// Applies the product of a function over a range of values.
120+ /// Example:
121+ /// ```
122+ /// product(1, 5, i -> i * i) // returns 14400 (1^2 * 2^2 * 3^2 * 4^2 * 5^2)
123+ /// product(1, 5, i -> i) // returns 120 (1 * 2 * 3 * 4 * 5)
124+ /// product(0, 0, i -> i) // returns 0 (0)
125+ /// ```
126+ /// @param min the minimum value to start the summation. Must be smaller or equal to max.
127+ /// @param max the maximum value to end the summation. Must be greater or equal to min.
128+ /// @param productFunction the function to apply to each value in the range before summing them up.
129+ /// @return the summation of the function applied to each value in the range
130+ /// @throws IllegalArgumentException if min is greater than max
141131 public static long product (long min , long max , LongFunction <Long > productFunction ) {
142132
143133 if (min > max ) {
0 commit comments