TwinFrame

ThreeDigitNaturalNumbers

Mar 19th, 2022 (edited)
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ThreeDigitNaturalNumbers
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int numberN;
  14.             int minNumberN = 1;
  15.             int maxNumberN = 27;
  16.             int firstFourDigitNumber = 1000;
  17.  
  18.             Random random = new Random();
  19.  
  20.             numberN = random.Next(minNumberN, maxNumberN + 1);
  21.  
  22.             int countThreeDigitNumber = 0;
  23.             for (int i = numberN; i < firstFourDigitNumber; i += numberN)
  24.             {
  25.                 if (i < firstFourDigitNumber)
  26.                     countThreeDigitNumber++;
  27.             }
  28.  
  29.             Console.Write($"Количество трехзначных натуральных чисел, которые кратны {numberN}: {countThreeDigitNumber}");
  30.             Console.ReadKey();
  31.         }
  32.     }
  33. }
Add Comment
Please, Sign In to add comment