fork download
  1. from fractions import *
  2.  
  3. def f(k,n):
  4. if n <= 2:
  5. return 0
  6. if k < 1 or k > n:
  7. return 0
  8. if n == 3:
  9. if 1 == k == 3:
  10. return Fraction(1,3)
  11. if k == 2:
  12. return Fraction(-2,3)
  13. return (Fraction(6*(k-n)*(k-1),(n-2)*(n-1)) + 1)*Fraction(30,n*(n+1)*(n+2))
  14.  
  15. temp = f(2,12)
  16. print(temp)
  17. print(float(temp))
Success #stdin #stdout 0.14s 14736KB
stdin
Standard input is empty
stdout
25/4004
0.006243756243756244