Skip to content

Instantly share code, notes, and snippets.

@FirroC
Created June 20, 2025 15:38
Show Gist options
  • Save FirroC/c5d22780d832fe15efabafc091b51c2b to your computer and use it in GitHub Desktop.
Save FirroC/c5d22780d832fe15efabafc091b51c2b to your computer and use it in GitHub Desktop.
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