daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Aug 19th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top