Sha256: 48a5108b23c545b8444352bb5768f5fcd0912b52e1cfbd2107ca80c4f885b023
Contents?: true
Size: 503 Bytes
Versions: 148
Compression:
Stored size: 503 Bytes
Contents
using System; using System.Linq; public static class Squares { public static int SquareOfSums(int max) { var numbers = Enumerable.Range(1, max); int sum = numbers.Sum(); return sum * sum; } public static int SumOfSquares(int max) { var numbers = Enumerable.Range(1, max); return numbers.Select(x => x * x).Sum(); } public static int DifferenceOfSquares(int max) { return SquareOfSums(max) - SumOfSquares(max); } }
Version data entries
148 entries across 148 versions & 1 rubygems