Advertisement
lightb01

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

Jun 29th, 2022 (edited)
931
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CSTemp
  8. {
  9.     internal class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Random random = new Random();
  14.             int number = 2;
  15.             int randomMin = 2;
  16.             int randomMax = 1000;
  17.             int targetNumber = random.Next(randomMin, randomMax);
  18.             int degree = 0;
  19.  
  20.             for (int i = number; (i < targetNumber * number); i *= number)
  21.             {
  22.                 degree++;
  23.             }
  24.  
  25.             Console.WriteLine($"Степень: {degree}, само число: {targetNumber}.");
  26.             Console.ReadKey();
  27.         }
  28.     }
  29. }
Advertisement
RAW Paste Data Copied
Advertisement