Last active
January 9, 2024 11:57
-
-
Save tsk-arh/7537feb59bde02e3f703aff64edbe3be to your computer and use it in GitHub Desktop.
ЗАДАНИЕ Сумма чисел
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApp4 | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Random rand = new Random(); | |
int randomMin = 0; | |
int randomMax = 100; | |
int value = rand.Next(randomMin, randomMax += 1); | |
int sum = 0; | |
int argument1 = 3; | |
int argument2 = 5; | |
for (int i = 0; i <= value; i++) | |
{ | |
if (i % argument1 == 0 || i % argument2 == 0) | |
sum += i; | |
} | |
Console.WriteLine($"Сумма чисел меньше или равных {value} и при этом кратных {argument1} или {argument2} равна {sum}"); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment