using System;
namespace algorithms
{
public class Program
public static void Main(string[] args)
System.Console.WriteLine(ConvertDecToBin(1782));
}
public static string ConvertDecToBin(int dec)
var s = string.Empty;
while (true)
s += dec % 2;
dec /= 2;
if (dec == 0)
break;
return Reverse(s);
public static string Reverse(string s)
char[] с = s.ToCharArray();
Array.Reverse(s.ToCharArray());
return new string (с);