Sha256: 96730b9bfd7df259f0b3d0472f93bfcde8b052a689075ce20fedceebad6d3737

Contents?: true

Size: 466 Bytes

Versions: 158

Compression:

Stored size: 466 Bytes

Contents

using System;

public static class Grains
{
    public static ulong Square(int n)
    {
        if (n <= 0 || n > 64)
        {
            throw new ArgumentOutOfRangeException(nameof(n));
        }

        return n == 1
            ? 1
            : 2 * Square(n - 1);
    }

    public static ulong Total()
    {
        ulong total = 0;

        for (int i = 1; i <= 64; i++)
        {
            total += Square(i);
        }

        return total;
    }
}

Version data entries

158 entries across 158 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.179 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.178 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.177 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.176 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.175 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.174 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.173 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.172 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.171 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.170 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.169 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.167 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.166 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.165 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.164 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.163 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.162 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.161 tracks/csharp/exercises/grains/Example.cs
trackler-2.2.1.160 tracks/csharp/exercises/grains/Example.cs