tracks/csharp/exercises/difference-of-squares/Example.cs in trackler-2.0.8.14 vs tracks/csharp/exercises/difference-of-squares/Example.cs in trackler-2.0.8.15

- old
+ new

@@ -1,35 +1,23 @@ using System; using System.Linq; -public class Squares +public static class Squares { - private readonly int max; - - public Squares(int max) + public static int SquareOfSums(int max) { - if (max < 0) - { - throw new ArgumentOutOfRangeException("Max must be positive", "max"); - } - - this.max = max; - } - - public int SquareOfSums() - { var numbers = Enumerable.Range(1, max); int sum = numbers.Sum(); return sum * sum; } - public int SumOfSquares() + public static int SumOfSquares(int max) { var numbers = Enumerable.Range(1, max); return numbers.Select(x => x * x).Sum(); } - public int DifferenceOfSquares() + public static int DifferenceOfSquares(int max) { - return SquareOfSums() - SumOfSquares(); + return SquareOfSums(max) - SumOfSquares(max); } } \ No newline at end of file