using System; public class Test { public static void Main() { for(var i = 0; i < 15; i++) Console.WriteLine ("#{0}: actual: {1}, estimated: {2}", i, GetActualCount(i), i * (i + 1) * (i + 2) / 6); } static int GetActualCount(int n) { var count = 0; for (int i = 0; i < n; i++) for (int j = 0; j <= i; j++) for (int k = 0; k <= j; k++) count++; return count; } }
Standard input is empty
#0: actual: 0, estimated: 0 #1: actual: 1, estimated: 1 #2: actual: 4, estimated: 4 #3: actual: 10, estimated: 10 #4: actual: 20, estimated: 20 #5: actual: 35, estimated: 35 #6: actual: 56, estimated: 56 #7: actual: 84, estimated: 84 #8: actual: 120, estimated: 120 #9: actual: 165, estimated: 165 #10: actual: 220, estimated: 220 #11: actual: 286, estimated: 286 #12: actual: 364, estimated: 364 #13: actual: 455, estimated: 455 #14: actual: 560, estimated: 560