Problem 138. Number of 1s in the Binary Representation of a Number


Return the number of 1s in the (unsigned integer) binary representation of a number. This function should be able to provide vectorized input and return an output with the same dimensions as the input.


   in = 215
   out = 6 

Solution Stats

36.22% Correct | 63.78% Incorrect
Last solution submitted on Oct 23, 2016

Problem Comments

Solution Comments

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more