Fibonacci sequence using reduce method
问题 So, I saw someone using the reduce method to calculate the Fibonacci sequence. Here is his idea: (1,0) , (1,1) , (2,1) , (3,2) , (5,3) corresponds to 1, 1, 2, 3, 5, 8, 13, 21 ....... and the code looks like this def fib_reduce(n): initial =(1,0) dummy = range(n) fib_n = reduce(lambda prev ,b : (prev[0] + prev[1], prev[0]), dummy, initial) return fib_n[0] I understand the (prev[0] + prev[1] , prev[0]) which is like a, b = b, b + a . However, I don't understand what this b stands for ? May