Sort by

recency

|

487 Discussions

|

  • + 0 comments
    def fibonacci(n):
        a = 0
        b = 1
        c = []
        for i in range(1,n+1):
            c.append(a)
            d = a + b
            a = b
            b = d
        return c
            
    cube = (lambda x: (x**3))
    
    if __name__ == '__main__':
    
    n = int(input())
    print(list(map(cube, fibonacci(n))))
    
  • + 0 comments

    This is the method to make real fibonnaci # complete the lambda function def fibonacci(n): a = 0 b = 1 c = [] for i in range(1,n+1): c.append(a) d = a + b a = b b = d return c

    # return a list of fibonacci numbers
    

    cube = (lambda x: (x**3))

    if name == 'main': n = int(input()) print(list(map(cube, fibonacci(n))))

  • + 0 comments

    I think this is the easiest one

    Code:

    cube = lambda x: x**3 # complete the lambda function 
    
    def fibonacci(n):
        # return a list of fibonacci numbers
        fibseq = [0, 1]
    
        if n > 2:
            for i in range(2, n):
                fibseq.append(fibseq[i - 2] + fibseq[i - 1])
        else:
            fibseq = fibseq[:n]
        
        return fibseq
        
    if __name__ == '__main__':
        n = int(input())
        print(list(map(cube, fibonacci(n))))
    
  • + 0 comments
    cube = lambda x:x**3 # complete the lambda function 
    
    def fibonacci(n):
        # return a list of fibonacci numbers
        if n == 0:
            return []
        elif n == 1:
            return [0]
        else:
            fib = [0, 1]
            for i in range(2, n):
                fib.append(fib[i - 1] + fib[i - 2])
            return fib 
    
  • + 0 comments
    cube = lambda x: x ** 3
    
    def fibonacci(n):
        fib = [0, 1]  
        for _ in range(2, n):
            fib.append(fib[-1] + fib[-2])  
        return fib[:n]  
    
    if __name__ == '__main__':
        n = int(input())
        print(list(map(cube, fibonacci(n))))