Advertisement
tanya_zheleva

1

Feb 18th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Numerics;
  5.  
  6. namespace ExamPreparation
  7. {
  8.     public sealed class Preparation
  9.     {
  10.         public static void Main()
  11.         {
  12.             BigInteger[] tokens = Console.ReadLine()
  13.                 .Split()
  14.                 .Select(BigInteger.Parse)
  15.                 .ToArray();
  16.  
  17.             BigInteger @base = tokens[0];
  18.             BigInteger number = tokens[1];
  19.  
  20.             string result = string.Empty;
  21.             if (@base >= 2 && @base <= 10)
  22.             {
  23.                 while (number > 0)
  24.                 {
  25.                     BigInteger remainder = number % @base;
  26.                     number /= @base;
  27.                     result = remainder.ToString() + result;
  28.                 }
  29.  
  30.                 Console.WriteLine(result);
  31.             }
  32.             else
  33.             {
  34.                 Console.WriteLine(0);
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement