Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,840 --> 00:00:08,700
So let's make this quick exercise together, guys, because previously we know that the previous exercise
2
00:00:08,700 --> 00:00:15,390
when we had to write down a recursive function that gets an integer and returns one, if the sum of
3
00:00:15,390 --> 00:00:20,440
all the digits in the received number is even otherwise, return zero if it's odd.
4
00:00:20,730 --> 00:00:24,420
And basically we are going simply to modify it a little bit.
5
00:00:24,420 --> 00:00:25,600
So return one.
6
00:00:25,600 --> 00:00:32,580
If the sum of all digits in the received number is odd or otherwise return one, which means in the
7
00:00:32,580 --> 00:00:40,050
case that this sum is even OK.
8
00:00:40,050 --> 00:00:44,010
So very minor a change, very minor change.
9
00:00:44,010 --> 00:00:45,740
In this case, it's going to be zero.
10
00:00:45,750 --> 00:00:47,310
In this case it's going to be one.
11
00:00:47,310 --> 00:00:48,180
In this example.
12
00:00:49,170 --> 00:00:56,850
I just want to like to give it briefly for those of you who is who are interested, maybe some of you
13
00:00:57,510 --> 00:01:02,930
got the idea and you don't have to watch these video to her to the fullest or basically not at all.
14
00:01:03,390 --> 00:01:03,780
So.
15
00:01:05,090 --> 00:01:09,890
I'm just going to modify it a little bit to give you this code like crystal clear.
16
00:01:09,920 --> 00:01:15,330
OK, so if anything, less than 10 and basically that's the stopping condition.
17
00:01:16,130 --> 00:01:20,810
And if that's the case, we know that it can be divided by two without the remainder.
18
00:01:21,170 --> 00:01:24,300
OK, so this is an even number, right?
19
00:01:24,470 --> 00:01:26,870
So that means even number.
20
00:01:27,500 --> 00:01:30,540
And for an even number, we are going to return.
21
00:01:30,710 --> 00:01:32,160
What are we going to return?
22
00:01:32,390 --> 00:01:34,490
We are going to return one.
23
00:01:34,700 --> 00:01:35,040
OK.
24
00:01:35,060 --> 00:01:36,890
So in.
25
00:01:39,050 --> 00:01:49,490
Yeah, what if it's an even number we're going to return, we are going to return here zero, so OK,
26
00:01:49,700 --> 00:01:51,230
otherwise return zero.
27
00:01:51,260 --> 00:01:52,940
In case that's an even number.
28
00:01:52,970 --> 00:01:53,380
Awesome.
29
00:01:53,660 --> 00:01:56,150
So if that's an even number, return zero.
30
00:01:56,600 --> 00:02:06,320
And if that's an odd number, that's basically all the number we are going through a third one and the
31
00:02:06,320 --> 00:02:10,100
result so far is going to be calculated on the similar manner.
32
00:02:10,320 --> 00:02:17,150
OK, we are going to ask if An can be divided, basically the rightmost digit, if it's an even digit
33
00:02:17,450 --> 00:02:23,150
and the result so far is one, then in this case what we will have to return.
34
00:02:23,270 --> 00:02:24,080
What do you think?
35
00:02:24,500 --> 00:02:30,370
If the result so far equals to one, then it means that the result so far is order.
36
00:02:31,040 --> 00:02:31,450
Right.
37
00:02:31,850 --> 00:02:39,650
And if the results so far resolved and this number is even then even plus odd is basically odd.
38
00:02:39,860 --> 00:02:42,250
So that's why we have to return one.
39
00:02:43,280 --> 00:02:50,510
And if the result so far was equal to zero, in this case it was even right.
40
00:02:50,900 --> 00:02:59,960
And if it was even then, the result so far is even and we also know that the given value, the rightmost
41
00:02:59,960 --> 00:03:06,890
element of the rightmost digit is also even then in this case even plus even will equal to even.
42
00:03:07,190 --> 00:03:11,570
And that will mean that the return should be once again, zero.
43
00:03:12,590 --> 00:03:16,970
OK, so here it's going to also stay the same.
44
00:03:17,060 --> 00:03:17,430
OK.
45
00:03:17,450 --> 00:03:23,660
The only fact that change is here is not the code itself, but rather just this understanding.
46
00:03:23,690 --> 00:03:29,840
So if results of equals to one, then it means that the result so far was odd.
47
00:03:30,000 --> 00:03:32,660
OK, otherwise it was even.
48
00:03:32,690 --> 00:03:38,360
So that's basically just the way you look at the results so far and you don't have to change also these
49
00:03:38,360 --> 00:03:39,070
returns.
50
00:03:39,830 --> 00:03:45,830
So this exhibition or a demonstration, quick explanation is clear to you guys.
51
00:03:46,430 --> 00:03:53,900
And of course, take your time, try to solve it on your own and we will see each other again on in
52
00:03:53,900 --> 00:03:54,660
or.
53
00:03:54,980 --> 00:03:55,370
Yeah.
54
00:03:55,400 --> 00:03:57,830
In the next video until next time.
55
00:03:57,860 --> 00:03:59,590
My name is Lisas Alphatech.
56
00:03:59,600 --> 00:04:00,380
I'll see you then.
5129
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.