Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Returning the number of 1s in the binary representation of an unsigned integer
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Hello, world!"); uint inputUnsignedInt = 7; uint halved = inputUnsignedInt; uint totalNumBerOfOnes = 0; while (halved >= 1) { if (halved % 2 == 1) { totalNumBerOfOnes++; } halved = halved / 2; } Console.WriteLine(totalNumBerOfOnes); } } }
run
|
edit
|
history
|
help
0
Bb
Inheritance
q1
test linq select
Basic event
C# Events and Delegates example
Bubble Sort
Binary search, IComparer, in lambda expressions style
c# integers
sdfrgthyujyhtgrf