Video instructions and help with filling out and completing Form 2220 Consecutive

Instructions and Help about Form 2220 Consecutive

Hello friends my name is too sharp and today we are going to talk about the question number without consecutive ones in binary presentation so the question is given and find the total number of numbers from zero to Taurus to n minus 1 such that the numbers do not have consecutive ones in the binary presentation so for example here I have n is equal to 2 so I have numbers from 0 to 3 so let's see how many numbers do not have consequent ones in their binary presentation 1 2 & 3 so when is equal to 2 you should return 3 notice how this one has 1 1 consecutive ones in the binary representation let's see n is equal to 3 so here we have 5 numbers who do not have consecutive ones in the binary representation while there are 3 numbers 0 1 1 1 1 0 1 1 1 do have consecutive ones in the binary representation so when n is equal to 3 you fewer than 5 so how do we solve this we'll use this is a very simple implementation of a Fibonacci series let's see how it's a Fibonacci series here I have a binary representation for four bits number so this goes from 0 to 15 so this is 0 to 7 and this is 8 to 15 all right so let's see how it's a Fibonacci series so let's look at this half for this half notice how we are adding 0 in front of threes binary representation so these numbers are exactly same as this number only that my added 0 in front of them so the number of ones number of numbers who do not have conjugative once here will be exactly same as this class of 5 because 0 is not going to contribute to the - 1 so the 0 will not cause any number to become contributing 1 so we are just pretty much looking at representation from 0 0 0 to 1 1 1 and we already calculate that number is 5 the total number of numbers let's see for this half here four numbers were already ending with once and we added one in front of them so in the 3ds representation four numbers were already ending with once and we added one in front of them so these four numbers you can directly rule them out because they have consecutive ones so this four number is gone will not need them whatever the rest of the four numbers so this guy's do contribute these guys do have numbers who do not have consecutive ones so how do you find them here you see how we have four numbers left here and you have already calculated what is the number when here four numbers left which is four two so this number here is two so here we are looking at the total number of numbers who do not have consecutive ones will be what we already calculated for 0 0 0 1 1 0 1 1 which is this so the total for n is equal to 4 will be 5 plus 3 is equal to 8 notice how F of 4 was equal to F of 3 plus F of 2 all right if I was calculating 5 n is equal to 5 all I have to do is sum of F of 4 plus F of 3 so this is 8 plus 5 so 30 so this is how it's a Fibonacci series the formula for Fibonacci series is pretty straightforward f of n is equal to f of n minus 1 plus F of n minus 2 if you want a full solution for this part then go to my github link github.com machetes interview wiki and if you want to check out cellular questions go to my youtube channel youtube.com user too short right 25 25 thanks for watching this video