Advertisement
YavorGrancharov

Convert_from_base_10_to_base_N

Oct 25th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5.  
  6. namespace Convert_from_base_10_to_base_N
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             BigInteger[] input = Console.ReadLine().Split().Select(BigInteger.Parse).ToArray();
  13.  
  14.             BigInteger toBase = input[0];
  15.             BigInteger num = input[1];
  16.  
  17.             BigInteger reminder = 0;
  18.             List<BigInteger> result = new List<BigInteger>();
  19.             while ( num > 0)
  20.             {
  21.                 reminder = num % toBase;
  22.                 result.Add(reminder);
  23.                 num /= toBase;
  24.             }
  25.             result.Reverse();
  26.             Console.WriteLine(string.Join("",result));
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement