Created
June 20, 2025 15:38
-
-
Save FirroC/c5d22780d832fe15efabafc091b51c2b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Random random = new Random(); | |
int minNumberValue = 1; | |
int maxNumberValue = 101; | |
int randomNumber = random.Next(minNumberValue, maxNumberValue); | |
int sum = 0; | |
int firstDivisor = 3; | |
int secondDivisor = 5; | |
Console.WriteLine($"Случайное число: {randomNumber}"); | |
for (int i = 1; i <= randomNumber; i++) | |
{ | |
if (i % firstDivisor == 0 || i % secondDivisor == 0) | |
{ | |
sum += i; | |
} | |
} | |
Console.WriteLine($"Сумма чисел от 1 до {randomNumber} которые кратны {firstDivisor} или {secondDivisor}: {sum}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment