Skip to content

Instantly share code, notes, and snippets.

@gulbanana
Last active August 10, 2016 02:19
Show Gist options
  • Save gulbanana/bedeaf0fb609fac29d7ee42d459a502f to your computer and use it in GitHub Desktop.
Save gulbanana/bedeaf0fb609fac29d7ee42d459a502f to your computer and use it in GitHub Desktop.
pr15
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplicationList
{
class Program
{
static IEnumerable<long> BuildLatticeRow(int size)
{
if (size == 0)
{
yield return 1;
yield break;
}
var accumulator = 0L;
foreach (var element in BuildLatticeRow(size - 1))
{
accumulator += element;
yield return accumulator;
}
yield return accumulator * 2;
}
static void Main(string[] args)
{
var latticeRow = BuildLatticeRow(int.Parse(args[0]));
Console.WriteLine(latticeRow.Last());
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplicationList
{
class Program
{
static IEnumerable<long> BuildLatticeRow(int size)
{
if (size == 0)
{
yield return 1;
}
else
{
var accumulator = 0L;
foreach (var element in BuildLatticeRow(size - 1))
{
accumulator += element;
yield return accumulator;
}
yield return accumulator * 2;
}
}
static void Main(string[] args)
{
var latticeRow = BuildLatticeRow(int.Parse(args[0]));
Console.WriteLine(latticeRow.Last());
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment