Skip to content

Commit c4942a4

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

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
/**
44
* This program calculates the sum of the first n odd numbers.
5-
*
5+
*
66
* https://www.cuemath.com/algebra/sum-of-odd-numbers/
77
*/
88

9-
public final class SumOfOddNumbers
10-
{
11-
private SumOfOddNumbers()
12-
{
9+
public final class SumOfOddNumbers {
10+
private SumOfOddNumbers() {
1311
}
1412

1513
/**
@@ -18,10 +16,8 @@ private SumOfOddNumbers()
1816
* @param n the number of odd numbers to sum
1917
* @return sum of the first n odd numbers
2018
*/
21-
public static int sumOfFirstNOddNumbers(final int n)
22-
{
23-
if (n < 0)
24-
{
19+
public static int sumOfFirstNOddNumbers(final int n) {
20+
if (n < 0) {
2521
throw new IllegalArgumentException("n must be non-negative.");
2622
}
2723
return n * n;

0 commit comments

Comments
 (0)