Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int randomNumber;
- int multiplyeredNumber = 2;
- int maximalNumber = int.MaxValue / multiplyeredNumber;
- int currentPoweredNumber = 0;
- int currentDegreeNumber = 0;
- bool isPowLessThenRandomNumber = true;
- Random random = new Random();
- randomNumber = random.Next(1, maximalNumber);
- Console.WriteLine($"Случайное число от {1} до {maximalNumber}: {randomNumber}.");
- Console.WriteLine($"Степени числа {multiplyeredNumber} до степени превосходящей {randomNumber}:");
- for (int i = 0; isPowLessThenRandomNumber; i++)
- {
- isPowLessThenRandomNumber = Math.Pow(multiplyeredNumber, i) <= randomNumber;
- currentDegreeNumber = i;
- currentPoweredNumber = Convert.ToInt32(Math.Pow(multiplyeredNumber, i));
- Console.WriteLine($"Степень {i} числа {multiplyeredNumber} равна {currentPoweredNumber}");
- }
- Console.WriteLine($"{randomNumber} исходное число");
- Console.WriteLine($"{currentPoweredNumber} первая превосходящая степень числа {multiplyeredNumber}");
- Console.WriteLine($"Степень: {currentDegreeNumber}");
- Console.ReadKey();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement