Advertisement
Montagne94

16. Кратные числа

Jan 7th, 2025 (edited)
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 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.             int minValue = 50;
  10.             int maxValue = 150;
  11.            
  12.             int minNumber = 10;
  13.             int maxNumber = 25;
  14.             int randomNuber;
  15.  
  16.             Random random = new Random();
  17.             randomNuber = random.Next(minNumber, maxNumber + 1);
  18.  
  19.             int sum = 0;
  20.  
  21.             for (int i = 0; i <= maxValue; i += randomNuber)
  22.             {
  23.                 if (i >= minValue)
  24.                     sum++;
  25.             }
  26.            
  27.             Console.WriteLine($"Количество чисел, кратных {randomNuber}: {sum}");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement