Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
All right.
What is going on, ladies and gentlemen, and welcome to this video where we are going to develop a
recursive function that receives an integer number.
OK, so we are going to do some recursion.
Another exercise and you are going to become even better and you will get more knowledge and more experience
working with recursion.
So what do you have to do is to develop a recursive function that receives an integer number and all
the functions you do is it should observe the digits from left to right.
And then based on the order of these digits, the function should return one.
If the digits from left to right are very ascending, the function should return minus one if the digits
from left to right are very descending.
And the function should return is zero.
Otherwise.
So simply saying we look at the digits from left right and we say if they are incrementing from left
to right, we will return one if they are a discriminating from left to right.
We will return minus one.
And if we have any other case, like if maybe two digits are the same or basically if two digits, we
have one digits smaller than the other and then we have another digit smaller than this one.
Then basically, we can say that it's definitely not very ascending, neither.
It's also not a very descending a sequence of digits.
OK.
So.
We know that this exercise can be easily solved just by using some loops, right, we can use some loop
iterating over each and every one of the digits.
Probably we will do also the same here, but for now, because we are requested to develop a function,
a recursive function.
We will say, at least at the beginning, we will say, OK, we have.
First, the idea of using loops, let's take loops, put them aside and try to solve it in another way,
in a recursive manner.
When we are going to take a bigger problem, splitting it up to smaller problems, some problems in
making conclusions based on this day vision.
OK, that's what we are requested to do to write the recursive function.
Also, a couple of assumptions that we need to take into account is, first of all, that we can take
some assumption that the initial noun verb to function is going to receive is basically has more than
two digits, two digits and beyond.
OK, it's not just one one digit number.
If it was like if we had to take into consideration all the possibilities.
So basically just there were a couple of few changes that we would need to add.
But for now, we will assume that our now is at least of two digit size and all digits in some are different.
OK.
That's very important to take into account because if not, we would need to add a few more lines of
code.
That's basically something that we can do, but for now, that will be sufficient for us to work and
to develop these recursive function with these pretty much nice assumptions.
OK, so we have initial number of two plus digits and all digits in some are different.
No pair of digits are the same, meaning all the digits are going to be different.
In this example, we will simply use it like this.
OK, so all the digits will be different.
So for example, if we have, this number now equals two one two four, then we can say that the function
should return one.
Because if we take a look at the digits from left to right, we will see that the digits are very ascending.
If we will take a look at this one, we will see that although the digits seem to be very ascending,
the last digit is descending.
And that means that the sequence of these digits from left to right is neither very ascending nor very
descending.
Final option is when, whenever we return, minus one is when we have from left to right.
If we take a look at the digits and we see that they are very descending, meaning for every pair of
digits that we take, the left digit will be greater than the right one.
OK, so that's the function that you have to develop.
Take some time to think about what should be the solution.
How to approach this exercise.
Write some code on your own.
Try to run it using some function, some main call for these function and make sure that your idea works
and then compare it with the results that we are going to do together.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.