Count the number of 1s in the binary of a number

using System;
using System.Collections.Generic;

namespace Numberof1s
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = NumbersIn(100000101);
            int Count = 0;
            while(num.Count != 0)
            {
                if (num.Pop() ==1) Count++ ;
            }
            Console.WriteLine(Count);
            Console.Read();
        }

        public static Stack<int> NumbersIn(int value)
        {
            if (value == 0) return new Stack<int>();

            var numbers = NumbersIn(value / 10);

            numbers.Push(value % 10);

            return numbers;
        }
    }
}

results matching ""

    No results matching ""