A given positive integer n has binary expansion coefficients
Solution
Given binary (ak-1ak-2............a3a2a1a0 )
 
 Lets take example and then Go over the question
 1. Binary of 2 is (10) , 2*2 = 4 (Binary of 4 is 100 ) so whenever we multiply a number by 2 a zero is appended to its right. 4*2 = 8 (1000). So Its like Any Number x 2n = (AnyNumber00000..n times)
 2*8 = (10)*23 = (10000) ..So It works this way results in 16. [Multiplicatiion by 2n appends n bit at the end to output]
 
 2. [Division by 2n removes n bit from the end of input and gives us the output]
8/2 = 1000/21   = 100 , removes last one bit [4 is the answer ]
 16/4 = 10000/22 = 100 , removes last two bit [4 is the answer ]
 
 3. Modulus (%) means the remainder like 4 %2 = 0 & 4%3 = 1
 So it works this way 10%4 = 2 , So 10 & (4-1) = > 10 &3 = > 1010 & 0011 =>0010 [2]
 So any P modulo Q is [ P & (Q-1) ] where & is bitwise AND operator
 
 
 Now coming to our question.
 1. 8n : As we know multiplication of binary number by 8 added 23 i.e 3 zeros at the end of that number
 Our binary number is (ak-1ak-2............a3a2a1a0 )
 So 8n = (ak-1............a3a2a1a0 000)2
 
 2. n DIV 4: As we know when we divide a number n by any binary number of 2k .It removes k number of digits starting from LSB. For us its 2k So k =2 here.
 Our binary number is (ak-1ak-2............a3a2a1a0 ).
 So n DIV 4 = (ak-1............a3a2)2 => (00ak-1............a3a2)2 As we can see two LSB a1a0 are removed .
3. n MOD 4: As we know when we modulus a number n by any binary number of k. It does a bit wise AND of num n and k-1
 Our binary number is (ak-1ak-2............a3a2a1a0 ) and k =4 = > (ak-1ak-2............a3a2a1a0 ) & (3)
 So (ak-1ak-2............a3a2a1a0 ) & (0k-1.......0011) = (0k-10k-2............a1a0 )
 So n MOD 4 = (0k-10k-2............a1a0 )2 is the answer .
 
 
 Thanks, I hope it clarifies. Let me know if there is anything.
 

