Advertisement
rukvir

HW 2_9_2

Feb 19th, 2025
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. using System;
  2.  
  3. namespace HW_2025
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int count = 0;
  10.             int startDiapason = 50;
  11.             int endDiapason = 150;
  12.  
  13.             Random randomNumber = new Random();
  14.             int N = randomNumber.Next(10, 26);
  15.             Console.WriteLine($"Сгенерированное число N: {N}");
  16.             Console.WriteLine("----------------------------");
  17.  
  18.             for (int i = N; i <= endDiapason; i+=N)
  19.             {
  20.                 if(i >= startDiapason)
  21.                 {
  22.                     count++;
  23.                 }
  24.             }
  25.  
  26.             Console.WriteLine($"Количество чисел от 50 до 150, кратных {N}: {count}");
  27.             Console.ReadKey();
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement