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

Version Path
trackler-2.2.1.45 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.44 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.43 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.42 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.41 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.40 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.39 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.38 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.37 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.36 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.35 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.34 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.33 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.32 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.31 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.30 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.29 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.28 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.27 tracks/csharp/exercises/difference-of-squares/Example.cs
trackler-2.2.1.26 tracks/csharp/exercises/difference-of-squares/Example.cs