How to count the trailing zeros in a binary number using Java

1 Answer

0 votes
class Program {
    public static void main(String[] args) {
        int number = 80; // 1010000

		System.out.println("Number of Trailing Zeros: " + Integer.numberOfTrailingZeros(number));
    }
}



/*
run:

Number of Trailing Zeros: 4

*/

 



answered Apr 7, 2024 by avibootz
...