using System; class Program { static void Main(string[] args) { ulong val = 19; ulong powerOfTwo = NearestMinPowerOfTwo(val); Console.WriteLine(powerOfTwo); } static ulong NearestMinPowerOfTwo(ulong n) { if((n & (n - 1)) == 0) { return n; } return NearestMinPowerOfTwo(n-1); } }