Ad
  • Custom User Avatar

    sorry,not know the rules very much. some trains have discuss button in it, but not this

  • Custom User Avatar

    the code is very simple:
    def fib(n):
    """Calculates the nth Fibonacci number"""
    print(n)
    a,b = 0,1
    while n>1:
    if n%2 == 0:
    n-=2
    a,b = a+b, a+2b
    else:
    n-=1
    a,b = b, a+b
    #print(n,a,b)
    while n<0:
    if n%2 == 0:
    n+=2
    a,b = 2
    a-b, b-a
    else:
    n+=1
    a,b = b-a,a
    #print(n,a,b)
    if n==0:
    return a
    elif n==1:
    return b

    print(fib(1000000))

  • Custom User Avatar

    for fib(1000000)

    real 0m43.723s
    user 0m41.752s
    sys 0m0.206s

  • Custom User Avatar

    fib(84362)

  • Custom User Avatar

    for kata "The Millionth Fibonacci Kata", my code run no more than 0.4 seconds in my computer, why get a timeout @codewars?
    real 0m0.337s
    user 0m0.331s
    sys 0m0.005s

    if i don't add print in the program, just get a timeout with nothing
    if i add any print in the program, it just complains about too many print in my program

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution