Last active
April 21, 2025 13:24
-
-
Save Strelok78/654149a1b807ffce8e4b3a53422ff8f1 to your computer and use it in GitHub Desktop.
get power of two that bigger then random value (without Math.Pow operations)
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
using System.Diagnostics; | |
namespace iJuniorPractice; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Random random = new Random(); | |
int baseDegree = 2; | |
int multipleTemporaryValue = 1; | |
int randomValue = random.Next(); | |
int powerValue = 0; | |
randomValue = 8; | |
while (multipleTemporaryValue <= randomValue) | |
{ | |
multipleTemporaryValue *= baseDegree; | |
powerValue++; | |
} | |
Console.WriteLine("random value = {0}, power value = {1}, value = {2}, base degree = {3}", randomValue, powerValue, multipleTemporaryValue, baseDegree); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment