Advertisement
NikaBang

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

Oct 1st, 2024
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2.  
  3. internal class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int minRandom = 1;
  8.         int maxRandom = 101;
  9.         int numberRaisedDegree = 2;
  10.         int degree = 1;
  11.         int maxNumber = 0;
  12.         int number = new Random().Next(minRandom, maxRandom);
  13.  
  14.         for (int i = numberRaisedDegree; i<number; i *= numberRaisedDegree)
  15.         {
  16.             degree++;
  17.             maxNumber = i * numberRaisedDegree;
  18.         }
  19.  
  20.         Console.WriteLine($"{numberRaisedDegree} в степени {degree} превосходит {number} и равняется {maxNumber}");
  21.         Console.ReadKey();
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement