fork download
  1. def test(n):
  2. c = 0.0
  3. for j in range(n):
  4. for i in range(j + 1):
  5. c = c + 1
  6. return c
  7.  
  8. n = 10
  9. c = test(n)
  10. print(n, c, c / (n*n))
  11.  
  12. n = 20
  13. c = test(n)
  14. print(n, c, c / (n*n))
  15.  
  16. n = 50
  17. c = test(n)
  18. print(n, c, c / (n*n))
  19.  
  20. n = 100
  21. c = test(n)
  22. print(n, c, c / (n*n))
  23.  
  24.  
  25.  
Success #stdin #stdout 0.01s 7180KB
stdin
Standard input is empty
stdout
(10, 55.0, 0.55)
(20, 210.0, 0.525)
(50, 1275.0, 0.51)
(100, 5050.0, 0.505)