How to Find first set bit

bits

#1

Find first set bit
Given an integer an N, write a program to print the position of first set bit found from right side in the binary representation of the number.

I/P 18, Binary Representation 010010

O/P 2

I/P 19, Binary Representation 010011

O/P 1

Can anyone explain with the help of an example


#2

Refer this : https://www.hackerearth.com/practice/basic-programming/bit-manipulation/basics-of-bit-manipulation/tutorial/


#3

log2(number&(-number))+1 will give you the desired result.
Hope this help.