1 00:00:06,350 --> 00:00:10,190 Let's take a look at the Fibonacci sequence. 2 00:00:11,460 --> 00:00:19,770 A Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers. 3 00:00:19,920 --> 00:00:20,310 Right. 4 00:00:20,310 --> 00:00:26,910 So this might be something that you're already familiar with, but let's say we have a function called. 5 00:00:27,560 --> 00:00:30,710 Um, Fibonacci. 6 00:00:30,710 --> 00:00:34,520 And then we accept in as the parameter. 7 00:00:34,640 --> 00:00:35,060 Right. 8 00:00:35,060 --> 00:00:40,970 So we'll say that we want the Fibonacci of six. 9 00:00:44,370 --> 00:00:49,920 If the sequence of numbers is the sum of the two preceding numbers? 10 00:00:49,920 --> 00:00:53,130 Well, we we start out at one and. 11 00:00:54,350 --> 00:00:56,300 Put zero here for clarity. 12 00:00:57,840 --> 00:01:00,210 Zero plus one is one. 13 00:01:00,900 --> 00:01:03,380 Okay, So this is the first number. 14 00:01:03,390 --> 00:01:04,860 This is the second number. 15 00:01:05,130 --> 00:01:08,040 One plus one is two. 16 00:01:08,040 --> 00:01:09,870 So that is our third number. 17 00:01:10,260 --> 00:01:13,800 One plus two is three. 18 00:01:14,160 --> 00:01:15,870 That is our fourth number. 19 00:01:16,970 --> 00:01:20,150 Two plus three is five. 20 00:01:20,180 --> 00:01:27,050 That is our fifth number and three plus five is eight and that is our six number. 21 00:01:27,050 --> 00:01:31,730 So we can say the Fibonacci of six is equal. 22 00:01:32,740 --> 00:01:33,610 To eight. 23 00:01:34,780 --> 00:01:46,720 So the recursion for this would look something like the Fibonacci of N is equal to n plus. 24 00:01:48,150 --> 00:01:52,260 The Fibonacci of N minus one. 25 00:01:54,970 --> 00:02:05,080 Now as an exercise, I would like for you to try to implement the recursion for the Fibonacci sequence, 26 00:02:05,320 --> 00:02:06,640 and I'll give you a hint. 27 00:02:07,600 --> 00:02:09,580 You will need base cases. 28 00:02:10,210 --> 00:02:16,330 And the base cases are is if your number is equal to zero, then return zero. 29 00:02:16,330 --> 00:02:20,980 And if your number is equal to one, then return one. 30 00:02:20,980 --> 00:02:21,400 Right. 31 00:02:21,400 --> 00:02:25,030 So if num equals zero. 32 00:02:27,600 --> 00:02:32,010 Turn zero and then if numb equals one. 33 00:02:33,840 --> 00:02:34,890 Return. 34 00:02:37,250 --> 00:02:46,100 So now take a minute and try to implement this recursive algorithm and check to see how your results 35 00:02:46,100 --> 00:02:47,330 match up to mine.