Associated Course(s):
Must Do Interview Preparation
Sudo Placement 2019

Given an integer an **N.** The task is to print the position of **first set bit found from right side** in the binary representation of the number.

**Input:**

The first line of the input contains an integer T, denoting the number of test cases. Then T test cases follow. The only line of the each test case contains an integer N.

**Output:**

For each test case print in a single line an integer denoting the position of the first set bit found form right side of the binary representation of the number.** If there is no set bit print "0"**.

**Constraints:**

1 <= T <= 200

0 <= N <= 10^{6}

**Example:**

**Input:**

2

18

12

**Output:**

2

3

**Explanation:**

**Testcase 1:** Binary representation of the 18 is 010010, the first set bit from the right side is at position 2.

Author: harshitsidhwa

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

thanuvinu94 | 425 |

the_coder95 | 380 |

RishabhTanwar1 | 280 |

shubham3174 | 208 |

RitikRosan | 202 |

the_coder95 | 1226 |

RishabhTanwar1 | 1000 |

thanuvinu94 | 634 |

tathagat289 | 628 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4885 |

Quandray | 4547 |

Login to report an issue on this page.