using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FactoresPrimosNumero_Forms
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
int numero, resi, k;
string cadena = textBox2.Text;
numero = int.Parse(textBox1.Text);
k = 2;
if (!int.TryParse(textBox1.Text, out numero)) numero = -1;
if (numero < 2)
{
MessageBox.Show("Numeros negativos NO. \r\n Superiores a 2 por favor");
textBox1.Clear();
return;
}
while ((numero != 1))
{
resi = numero % k;
if ((resi == 0))
{
cadena += (k.ToString() + " x ");
textBox2.Text = cadena.Remove(cadena.Length - 2);
numero = numero / k;
}
else
{
k = k + 1;
}
}
}