1. /**
    2. * @param n: an integer
    3. * @return: an ineger f(n)
    4. */
    5. func Fibonacci(n int) int {
    6. // write your code here
    7. q, p := 0, 1
    8. if n <= 1 {
    9. return n - 1
    10. }
    11. for i := 2; i < n; i++ {
    12. sum := q + p
    13. q = p
    14. p = sum
    15. }
    16. return p
    17. }