Advertisement
aggressiveviking

Untitled

Mar 8th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _12.IntegerToBase
  4. {
  5.     class Program
  6.     {
  7.         public static void Main()
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int toBase = int.Parse(Console.ReadLine());
  11.             Algo(n, toBase);
  12.         }
  13.         static void Algo(int n, int toBase)
  14.         {
  15.             int remind = 0;
  16.             string answer = "";
  17.            
  18.             while (n > 0)
  19.             {
  20.                 remind = n % toBase;
  21.                 n /= toBase;
  22.                 answer = remind.ToString() + answer;
  23.             }
  24.  
  25.             Console.Write(answer);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement