We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
cube=lambdax:x**3deffibonacci(n):# return a list of fibonacci numbersfirst=0second=1fibonacci_list=[]ifn==0:return[]elifn==1:return[first]elifn==2:return[first,second]else:fibonacci_list.append(first)fibonacci_list.append(second)foriinrange(3,n+1):num=first+secondfibonacci_list.append(num)first=fibonacci_list[i-2]second=fibonacci_list[i-1]returnfibonacci_list
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Map and Lambda Function
You are viewing a single comment's thread. Return to all comments →