Posts

Showing posts from September, 2026

X to the power of X (X^X)

One of my sons asked an interesting question: what number raised to itself equals to 25? In other words, he wanted to find X such that X^X = 25. I decided to write a simple program (no GAI for a change, just vintage coding) to do that. The key observations here are: 1/ X^X is continuous in the real domain 2/ It grows monotonically  3/ It grows very fast With that in mind, the solution is a binary search. The lower bound is 1, the upper bound can be found quickly by doubling the number, then we perform a standard binary search (some nuances there just because we're dealing with floating-point numbers). Complexity stays around Log(Log(N)), hence very fast. Code is down below, cheers. Oh... and the answer to my son is the following: 2.96321964263916 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Exp { internal class Program { static void Main(string[] args) { double...