Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Palindromos de producto de 2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AldeaDigital
{
class Program
{
static void Main(string[] args)
{
int rangoMenor = 100;
int rangoMayor = 999;
List<int> listaPalindromos = new List<int>();
for (int i = rangoMenor; i <= rangoMayor; i++)
{
for (int j = rangoMenor; j < rangoMayor; j++)
{
int multiplicacion = i * j;
String multiplicacionString = multiplicacion.ToString();
if (multiplicacionString.SequenceEqual(multiplicacionString.Reverse()))
{
listaPalindromos.Add(multiplicacion);
}
}
}
Console.WriteLine(listaPalindromos.ToArray().Max() + " es el palindromo más grande derivado del producto de 2 números en el rango " + rangoMenor + " a " + rangoMayor);
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment