tracks/csharp/exercises/pascals-triangle/Example.cs in trackler-2.2.1.41 vs tracks/csharp/exercises/pascals-triangle/Example.cs in trackler-2.2.1.42
- old
+ new
@@ -1,16 +1,25 @@
using System.Collections.Generic;
+using System;
public static class PascalsTriangle
{
public static IEnumerable<IEnumerable<int>> Calculate(int rows)
{
+ if (rows < 0)
+ throw new ArgumentOutOfRangeException();
+
+ return IterateRows(rows);
+ }
+
+ private static IEnumerable<IEnumerable<int>> IterateRows(int rows)
+ {
for (var i = 1; i <= rows; i++)
{
yield return Row(i);
}
}
-
+
private static IEnumerable<int> Row(int row)
{
yield return 1;
var column = 1;
\ No newline at end of file