Advertisement
SaNik74

power of number two

Feb 17th, 2024 (edited)
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         Random random = new Random();
  6.         int minValue = 0;
  7.         int maxValue = 1000;
  8.         int givenNumber = random.Next(minValue, maxValue);
  9.         int numberRaisedToPower = 2;
  10.         int power = 2;
  11.         int numberInPower = 2;
  12.         int numberOfPower = 1;
  13.  
  14.         while (numberInPower < givenNumber)
  15.         {
  16.             numberInPower *= power;
  17.             numberOfPower++;
  18.         }
  19.  
  20.         Console.WriteLine($"Число - {givenNumber}\n" +
  21.             $"Степень - {numberOfPower}\n" +
  22.             $"Число {numberRaisedToPower} в заданой степени - {numberInPower}");
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement