[ ASSIGNMENT: ] Binary Numbers | Sololearn: Learn to code for FREE!

+40

[ ASSIGNMENT: ] Binary Numbers

Given a base-10 integer, n, convert it to binary (base-2). Print a single base-10 integer denoting the maximum number of consecutive 1's in the binary representation of n. Sample Input : 5 Sample Output : 1 The binary representation of 5 is 101, so the maximum number of consecutive 1's is 1. Sample Input : 13 Sample Output : 2 The binary representation of 13 is 1101, so the maximum number of consecutive 1's is 2. HappyCodings!:-)

1/24/2018 2:53:45 PM

Danijel Ivanović

35 Answers

New Answer

+25

https://code.sololearn.com/cZyJCcqIm8lW/?ref=app

+33

My one-liner in JavaScript https://code.sololearn.com/WY324e59208k/?ref=app

+23

Finally my solution !! 😆 https://code.sololearn.com/cN8eOM4NhvUw/?ref=app

+23

https://code.sololearn.com/cfTqfPs5WU9H/?ref=app

+19

https://code.sololearn.com/cLdfg6QkP43U/?ref=app

+16

We finally started !! 👏😆👍 Thank you guys 👏😊😉 all of you !! 👍😆😎

+16

Here's my attempt : ) https://code.sololearn.com/cpmxMn383x6r/?ref=app

+15

@Pyctam and ?!!! I'm Bosnian 😆

+15

my try with python https://code.sololearn.com/cUhdEyBKga1y/?ref=app

+15

@Russ Make your code Public !! 😉

+14

Man... A little bit complicated, but here is my try. Good challenge! ✌👍👌 https://code.sololearn.com/c31eOUW1noxR/?ref=app

+11

Here’s mine: https://code.sololearn.com/WEnczr97HHTy/?ref=app

+11

Here is mine https://code.sololearn.com/c0CWeufHPutc/?ref=app

+11

https://code.sololearn.com/cEA9Z0ev7oqU/?ref=app

+9

my try!! https://code.sololearn.com/cTnN7rzLE5Q7/?ref=app

+8

My C++ solution https://code.sololearn.com/cVCJekO053HT/#cpp

+8

hi. my solution in cs https://code.sololearn.com/c66I5WIZ6hzO/?ref=app

+8

My solution in C: https://code.sololearn.com/csjy7n01TbQB/#c

+8

My entry https://code.sololearn.com/cmvDMS0pHvFA/?ref=app

+7

Another one in C https://code.sololearn.com/cSf7NoRW9l5T/?ref=app