Last active
May 16, 2023 16:09
-
-
Save Strelok78/39caf07dff26adff968fa428c30b8eac to your computer and use it in GitHub Desktop.
Finds the minimum power of two that exceeds the specified number.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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