Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. public class Bits {
  2. public static void main (String[] args) {
  3. int N = Integer.parseInt(args[0]);
  4. int times = 0;
  5. //number of time I need to divide N by 2 until it's less than 1.
  6. while (N/2 >= 1) {
  7. times = times + 1;
  8. N = N/2;
  9. }
  10. if (N < 0) System.out.println("illegal input");
  11. else System.out.println(times);
  12. }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement