Ejercicio
Múltiplos
Objetivo
Cree un programa en C# para escribir en pantalla los números del 1 al 500 que son múltiplos de 3 y también múltiplos de 5 (sugerencia: use el resto de la división).
Código de Ejemplo
using System; // Importing the System namespace to use Console functionalities
class Program
{
// Main method where the program execution begins
static void Main()
{
// Using a for loop to iterate through numbers from 1 to 500
for (int i = 1; i <= 500; i++) // Looping through numbers 1 to 500
{
// Checking if the current number is divisible by both 3 and 5
if (i % 3 == 0 && i % 5 == 0) // If the remainder of i divided by 3 and 5 is zero
{
// Displaying the number if it is divisible by both 3 and 5
Console.WriteLine(i); // Printing the number on the screen
}
}
}
}