- Reaction score
- 1,694
Here's the (alpha version) code. It's late at night, so bear with me. Will edit post.
Forgot to add a picture.
PHP:
using System;
namespace Practice
{
public class Lesson_2
{
public static void Main()
{
/*
* Integer to Binary Representation
*
* TODO:
* 1. Will try taking Binary to Integer
* Representation challenge.
* 2. Will cleanup the code. It gives error when
* no input is made before pressing Enter.
*
* Commented out the goto statement, unless you
* want to test how far this program can go.
*
* Finished this program in the middle of the
* night. I have school tomorrow.
*
*/
ulong number;
//retry:
Console.Write("Enter a value: ");
number = UInt64.Parse(Console.ReadLine());
Binary(number);
Console.WriteLine();
//goto retry;
}
private static void Binary(ulong number)
{
ulong remainder;
remainder = number % 2;
if (number >= 2)
Binary(number / 2);
Console.Write("{0}", remainder);
}
}
}
Forgot to add a picture.