fork download
  1. #for n in range(1,11):
  2. #print n%2, n-2*(n//2)
  3.  
  4. #f(n) == {g(n) : n is odd; h(n) : n is even}
  5. #f(n) == (n-2*(n//2))*g(n) + ((n+1)-2*((n+1)//2))*h(n)
  6.  
  7. def f(n):
  8. return (n-2*(n//2))*g(n) + ((n+1)-2*((n+1)//2))*h(n)
  9.  
  10. def g(n):
  11. return 0
  12.  
  13. def h(n):
  14. return n
  15.  
  16. for n in range(1,11):
  17. print f(n)
Success #stdin #stdout 0.01s 7692KB
stdin
Standard input is empty
stdout
0
2
0
4
0
6
0
8
0
10