Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Homework2_4
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- int minNumber = 1, maxNumber = 101;
- int number = random.Next(minNumber, maxNumber);
- int firstDivisor = 3, secondDivisor = 5;
- int sum = 0;
- Console.WriteLine("Рандомное число: " + number);
- for(int i = 1; i <= number; i++)
- {
- if (i % firstDivisor == 0 || i % secondDivisor == 0)
- {
- Console.WriteLine(i);
- sum += i;
- }
- }
- Console.WriteLine("Сумма всех положительных чисел: " + sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement