Skip to content

Commit 3a76b59

Browse files
authored
Update SumOfOddNumbers.java
1 parent 7fd4681 commit 3a76b59

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main/java/com/thealgorithms/maths/SumOfOddNumbers.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
* https://www.cuemath.com/algebra/sum-of-odd-numbers/
77
*/
88

9-
public final class SumOfOddNumbers {
10-
private SumOfOddNumbers() {
9+
public final class SumOfOddNumbers
10+
{
11+
private SumOfOddNumbers()
12+
{
1113
}
1214

1315
/**
@@ -16,9 +18,10 @@ private SumOfOddNumbers() {
1618
* @param n the number of odd numbers to sum
1719
* @return sum of the first n odd numbers
1820
*/
19-
20-
public static int sumOfFirstNOddNumbers(final int n) {
21-
if (n < 0) {
21+
public static int sumOfFirstNOddNumbers(final int n)
22+
{
23+
if (n < 0)
24+
{
2225
throw new IllegalArgumentException("n must be non-negative.");
2326
}
2427
return n * n;

0 commit comments

Comments
 (0)