Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Numerics;
  4.  
  5. namespace _2_Convert_from_Base_N_to_Base_10
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string[] input = Console.ReadLine().Split().ToArray();
  12.             int n = int.Parse(input[0]);
  13.             char[] number = input[1].ToCharArray();
  14.             BigInteger result = new BigInteger();
  15.  
  16.             for (int i = 0; i < number.Length; i++)
  17.             {
  18.                 int curentNum = (int)char.GetNumericValue(number[i]);
  19.                 result += curentNum * BigInteger.Pow(n, number.Length - i - 1);
  20.  
  21.             }
  22.             Console.WriteLine(result);
  23.            
  24.         }
  25.        
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement