CSharp · Console
using System;
public class Program
{
static int GetFirstDigit(int k)
{
double lgg = k * Math.Log10(k);
int count = (int)lgg + 1; // кол-во цифр числа k^k
double pow = lgg + 1 - count;
int firstDigit = (int)Math.Pow(10.0, pow);
return firstDigit;
}
public static void Main()
{
Console.WriteLine("UniLecs");
Console.WriteLine(string.Format("Answer = {0}", GetFirstDigit(3))); // 2; 3^3 = 27;
Console.WriteLine(string.Format("Answer = {0}", GetFirstDigit(4))); // 2; 4^4 = 256
Console.WriteLine(string.Format("Answer = {0}", GetFirstDigit(5))); // 3; 5^5 = 3125
}
}