Md_Sakib_Hossain

Highest Consecutive 1's binary representation

Aug 2nd, 2021 (edited)
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. //There is another class to handle this called Compiler class this class is used to get //ride of using scanner class multiple types for different problems
  2. //Compiler class just have object of this class-> Question_4 q4 = new Question_4(4);
  3.  
  4. public class Question_4(int N){
  5.  
  6.  Question_4{
  7.   int count = 0;
  8.   int highest = 1;
  9.  
  10.   for(int i=N; i>0; i++){
  11.    if(N%2==0){
  12.     count++;
  13.     System.out.println(count);
  14.    }
  15.    if(N%2==0){
  16.     System.out.println("Testing purpose I use this println and saw this problem");
  17.    }
  18.    N=N>>1;
  19.   }
  20.   System.out.println(highest);
  21.  }
  22.  
  23. }
Add Comment
Please, Sign In to add comment