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