Skip to content

Instantly share code, notes, and snippets.

@42BOBREEK
Last active February 6, 2025 20:19
Show Gist options
  • Save 42BOBREEK/71c5f3f3788c283e300e7a74d9f21c98 to your computer and use it in GitHub Desktop.
Save 42BOBREEK/71c5f3f3788c283e300e7a74d9f21c98 to your computer and use it in GitHub Desktop.
using System;
using System.Text;
namespace DZ1
{
internal class Program
{
static void Main(string[] args)
{
Random rand = new Random();
int number = rand.Next(0, 101);
int sum = 0;
int divisor1 = 3;
int divisor2 = 5;
Console.WriteLine($"Число - {number}");
for (int i = 0; i <= number; i++)
{
if (i % divisor1 == 0 || i % divisor2 == 0)
{
sum += i;
}
}
Console.WriteLine($"Сумма всех положительных чисел меньше number (включая число), которые кратные {divisor1} или {divisor2} - {sum}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment