6 kyu

Bit Counting

6,684 of 254,353xcthulhu

Description:

Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative.

Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case

Bits
Algorithms

Stats:

CreatedOct 21, 2013
PublishedOct 21, 2013
Warriors Trained507149
Total Skips61700
Total Code Submissions602095
Total Times Completed254353
Ruby Completions6684
CoffeeScript Completions269
JavaScript Completions73385
Python Completions90888
C# Completions17963
Java Completions29054
PHP Completions6235
C Completions6598
Clojure Completions333
Rust Completions3420
Shell Completions440
NASM Completions154
Crystal Completions52
Go Completions3572
C++ Completions12794
Scala Completions626
Swift Completions1488
Groovy Completions94
Julia Completions165
Haskell Completions1179
TypeScript Completions4978
Elixir Completions267
COBOL Completions18
Prolog Completions29
Lua Completions178
D Completions22
Perl Completions5
Total Stars2542
% of votes with a positive feedback rating88% of 24247
Total "Very Satisfied" Votes19014
Total "Somewhat Satisfied" Votes4781
Total "Not Satisfied" Votes452
Ad
Contributors
  • xcthulhu Avatar
  • jhoffner Avatar
  • Javatlacati Avatar
  • user3482173 Avatar
  • GiacomoSorbi Avatar
  • jFrench661 Avatar
  • suic Avatar
  • brunolm Avatar
  • samhstn Avatar
  • mcamuzat Avatar
  • jetjake Avatar
  • Chrono79 Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • B1ts Avatar
  • lilsweetcaligula Avatar
  • jbristow Avatar
  • acjoker Avatar
  • Voile Avatar
  • Souzooka Avatar
  • FArekkusu Avatar
  • vp217 Avatar
  • DrLecter Avatar
  • hobovsky Avatar
  • zaxy78 Avatar
  • xavierguihot Avatar
  • stellartux Avatar
  • trashy_incel Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • FandaL Avatar
  • cwps Avatar
  • KayleighWasTaken Avatar
  • lv70 Avatar
Ad