We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7fd4681 commit 3a76b59Copy full SHA for 3a76b59
src/main/java/com/thealgorithms/maths/SumOfOddNumbers.java
@@ -6,8 +6,10 @@
6
* https://www.cuemath.com/algebra/sum-of-odd-numbers/
7
*/
8
9
-public final class SumOfOddNumbers {
10
- private SumOfOddNumbers() {
+public final class SumOfOddNumbers
+{
11
+ private SumOfOddNumbers()
12
+ {
13
}
14
15
/**
@@ -16,9 +18,10 @@ private SumOfOddNumbers() {
16
18
* @param n the number of odd numbers to sum
17
19
* @return sum of the first n odd numbers
20
-
- public static int sumOfFirstNOddNumbers(final int n) {
21
- if (n < 0) {
+ public static int sumOfFirstNOddNumbers(final int n)
22
23
+ if (n < 0)
24
25
throw new IllegalArgumentException("n must be non-negative.");
26
27
return n * n;
0 commit comments