WOW! I solved the second puzzle after 1.5 days of RnD and hard work! Trying all the logic's thinking and patience always pays off!
From yestrday I wn working on this puzzle, may be for some of you it is not that much tricky but for me it was.
Feeling so happy after completing the puzzle at last.
Learn Share n Grow!
Solution 1:
From yestrday I wn working on this puzzle, may be for some of you it is not that much tricky but for me it was.
Feeling so happy after completing the puzzle at last.
Learn Share n Grow!
Objective
Today, we're working with binary numbers. Check out the Tutorial tab for learning materials and an instructional video!
Today, we're working with binary numbers. Check out the Tutorial tab for learning materials and an instructional video!
Task
Given a base- integer, , convert it to binary (base-). Then find and print the base- integer denoting the maximum number of consecutive 's in 's binary representation.
Given a base- integer, , convert it to binary (base-). Then find and print the base- integer denoting the maximum number of consecutive 's in 's binary representation.
Input Format
A single integer, .
Constraints
Output Format
Print a single base- integer denoting the maximum number of consecutive 's in the binary representation of .
Sample Input 1
5
Sample Output 1
1
Sample Input 2
13
Sample Output 2
2
package com.number;
import java.util.Scanner;
public class BinaryV2 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int rem=0,s=0,t=0;
while(n>0)
{
rem=n%2;
n=n/2;
if(rem==1)
{ s++;
if(s>=t)