fork download
  1. #!/usr/bin/env python3
  2.  
  3. def func(n):
  4. n = n - 1
  5. a = n // 3
  6. b = n // 5
  7. c = n // 15
  8. return a*(3 + a*3)//2 + b*(5 + b*5)//2 - c*(15 + c*15)//2
  9.  
  10. print(func(9))
  11. print(func(10))
Success #stdin #stdout 0.02s 8736KB
stdin
Standard input is empty
stdout
14
23