Advertisement
Montagne94

17. Степень двойки

Jan 7th, 2025 (edited)
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | Source Code | 0 0
  1. using System;
  2.  
  3. namespace HomeWork
  4. {
  5.     internal class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             Random random = new Random();
  10.             int min = 1;
  11.             int max = 101;
  12.             int number;
  13.             int exponentiatedNumber = 2;
  14.  
  15.             int power = 0;
  16.             int result = 1;
  17.  
  18.             number = random.Next(min, max + 1);
  19.             Console.WriteLine($"Заданное число: {number}");
  20.  
  21.             while (result <= number)
  22.             {
  23.                 result *= exponentiatedNumber;
  24.                 power++;
  25.             }
  26.  
  27.             Console.WriteLine($"Минимальная степень двойки: {exponentiatedNumber}^{power} = {result}");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement