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
Padma narwade
asdxscddasdcf
c# kare çizimi
Konakubo Wall
Numbers separated by space
obrazek
arrays bidimencionales y tridimencionales
Enum.IsDefined
Programa_01_01_Declaracion_de_clases
The abstract factory design pattern implemented in c# using generics.