Last active
February 6, 2025 20:19
-
-
Save 42BOBREEK/71c5f3f3788c283e300e7a74d9f21c98 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.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