Advertisement
junniorrkaa

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

Aug 22nd, 2024 (edited)
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | Source Code | 0 0
  1. using System;
  2.  
  3. namespace CSLight
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int userInput;
  10.             int smallerNumber = 50;
  11.             int largerNumber = 150;
  12.             int smallerDeduction = 10;
  13.             int largerDeduction = 25;
  14.             int quantityNumber = 0;
  15.  
  16.             Console.WriteLine($"Ваш диапазон чисел ({smallerNumber},{largerNumber})");
  17.             Console.Write($"Введите число (>= {smallerDeduction}) и (<= {largerDeduction}): ");
  18.             userInput = Convert.ToInt32(Console.ReadLine());
  19.  
  20.             if (userInput < smallerDeduction || userInput > largerDeduction)
  21.             {
  22.                 Console.WriteLine($"\nНеверное число. \n");
  23.                 return;
  24.             }
  25.  
  26.                 for (int i = 0; i <= largerNumber; i += userInput)
  27.             {
  28.                 if (i < smallerNumber)
  29.                 {
  30.                     continue;
  31.                 }
  32.  
  33.                 quantityNumber++;
  34.  
  35.             }
  36.  
  37.             Console.WriteLine(quantityNumber);
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement