Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace HomeWork
- {
- internal class Program
- {
- public static void Main(string[] args)
- {
- Random random = new Random();
- int firstDivider = 3;
- int secondDivider = 5;
- int minNumber = 1;
- int maxNumber = 100;
- int number = random.Next(minNumber, maxNumber + 1);
- Console.WriteLine($"Случайное число: {number}");
- int sum = 0;
- for (int i = 1; i <= number; i++)
- if (i % firstDivider == 0 || i % secondDivider == 0)
- sum += i;
- Console.WriteLine($"Сумма всех положительных чисел меньше {number}, кратных {firstDivider} или {secondDivider}: {sum}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement