Skip to content

Instantly share code, notes, and snippets.

@Strelok78
Last active May 16, 2023 16:09
Show Gist options
  • Save Strelok78/39caf07dff26adff968fa428c30b8eac to your computer and use it in GitHub Desktop.
Save Strelok78/39caf07dff26adff968fa428c30b8eac to your computer and use it in GitHub Desktop.
Finds the minimum power of two that exceeds the specified number.
namespace MyCode
{
internal class Program
{
static void Main(string[] args)
{
Random random = new Random();
int maxNumber = 100;
int numberToPower = 2;
int power = 0;
int number = random.Next(maxNumber);
while (Math.Pow(numberToPower, power) < number)
{
power++;
}
Console.WriteLine($"Number exceeding {number} is {numberToPower} to the power of {power}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment