Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Bits {
- public static void main (String[] args) {
- int N = Integer.parseInt(args[0]);
- int times = 0;
- //number of time I need to divide N by 2 until it's less than 1.
- while (N/2 >= 1) {
- times = times + 1;
- N = N/2;
- }
- if (N < 0) System.out.println("illegal input");
- else System.out.println(times);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement