Project Euler #76: Counting summations

  • + 0 comments

    C# Code

    using System;

    class Program { static ulong GetWays(int n) { ulong[] a = new ulong[n + 1]; a[0] = 1;

        for (int j = 1; j < n; j++)
        {
            for (int i = j; i <= n; i++)
            {
                a[i] = (a[i] + a[i - j]) % 1000000007;
            }
        }
    
        return a[n] % 1000000007;
    }
    
    static void Main()
    {
        int t = int.Parse(Console.ReadLine());
    
        for (int i = 0; i < t; i++)
        {
            int n = int.Parse(Console.ReadLine());
            ulong ways = GetWays(n);
            Console.WriteLine(ways);
        }
    }
    

    }