We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 10: Binary Numbers
Day 10: Binary Numbers
Sort by
recency
|
2837 Discussions
|
Please Login in order to post a comment
For C#
int n = Convert.ToInt32(Console.ReadLine().Trim());
string binary = "";
int max = 0;
int sum = 0;
int remainder = 0;
for (int i = n; i > 0; i = i / 2)
{ remainder = i % 2; sum += remainder;
} binary = new string(binary.Reverse().ToArray());
Console.WriteLine(max);
I have completed this solution in Python 3 with a bigginer freindly logic
A simple one line solution for Python 3