fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. for(var i = 0; i < 15; i++)
  8. Console.WriteLine ("#{0}: actual: {1}, estimated: {2}",
  9. i,
  10. GetActualCount(i),
  11. i * (i - 1) / 2);
  12. }
  13.  
  14. static int GetActualCount(int n) {
  15. var count = 0;
  16.  
  17. for (int i = 0; i < n; i++)
  18. for (int j = 0; j < i; j++)
  19. count++;
  20.  
  21. return count;
  22. }
  23. }
Success #stdin #stdout 0.03s 33896KB
stdin
Standard input is empty
stdout
#0: actual: 0, estimated: 0
#1: actual: 0, estimated: 0
#2: actual: 1, estimated: 1
#3: actual: 3, estimated: 3
#4: actual: 6, estimated: 6
#5: actual: 10, estimated: 10
#6: actual: 15, estimated: 15
#7: actual: 21, estimated: 21
#8: actual: 28, estimated: 28
#9: actual: 36, estimated: 36
#10: actual: 45, estimated: 45
#11: actual: 55, estimated: 55
#12: actual: 66, estimated: 66
#13: actual: 78, estimated: 78
#14: actual: 91, estimated: 91