Last active
August 10, 2016 02:19
-
-
Save gulbanana/bedeaf0fb609fac29d7ee42d459a502f to your computer and use it in GitHub Desktop.
pr15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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