6 kyu

Bit Counting

18,031 of 255,455xcthulhu

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 Trained509417
Total Skips61859
Total Code Submissions604324
Total Times Completed255455
Ruby Completions6691
CoffeeScript Completions269
JavaScript Completions73669
Python Completions91318
C# Completions18031
Java Completions29167
PHP Completions6250
C Completions6650
Clojure Completions335
Rust Completions3435
Shell Completions440
NASM Completions155
Crystal Completions54
Go Completions3598
C++ Completions12861
Scala Completions629
Swift Completions1495
Groovy Completions96
Julia Completions165
Haskell Completions1186
TypeScript Completions5026
Elixir Completions267
COBOL Completions18
Prolog Completions29
Lua Completions182
D Completions23
Perl Completions6
Total Stars2549
% of votes with a positive feedback rating88% of 24292
Total "Very Satisfied" Votes19051
Total "Somewhat Satisfied" Votes4788
Total "Not Satisfied" Votes453
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