Last active
May 16, 2023 15:57
-
-
Save Strelok78/8a73040e896ca0d992e7c37e9c84bb30 to your computer and use it in GitHub Desktop.
Using Random to get a number that is less equal than 100. Finding the sum of all positive numbers less than numbers that are multiples of 3 or 5.
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
namespace MyCode | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int minValue = 0; | |
int maxValue = 100; | |
int divider1 = 3; | |
int divider2 = 5; | |
int number = new Random().Next(minValue, maxValue); | |
int sum = 0; | |
for (int i = 0; i <= randomValue; i++) | |
{ | |
if (i % divider1 == 0 || i % divider2 == 0) | |
{ | |
sum += i; | |
} | |
} | |
Console.WriteLine(sum); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment