You are on page 1of 3

EJERCICIOS

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 MARK_1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btnGENERAR_Click(object sender, EventArgs e)


{
int C, A;
A = 0;
for (C=1; C<=10; C=C+1)
{
A = A + C;
}
txtSUMA.Text = Convert.ToString(A);
}

private void btnMOSTRAR2_Click(object sender, EventArgs e)


{
int N, C, D;
N = Convert.ToInt32(txtNUMERO.Text);
if (N>0)
{
listBox1.Items.Clear();
for (C=1; C<=N; C=C+1)
{
D = N % C;
if (D==0)
{
listBox1.Items.Add(C);
}
}
}
else
{
MessageBox.Show("ERROR");
}
}

private void btnDETERMINAR_Click(object sender, EventArgs e)


{
int N, C, D, A;
N = Convert.ToInt32(txtNUMERO2.Text);
if (N>0)
{
C = 1;
A = 1;
while (C<=N)
{
D = N % C;
if (D==0)
{
A = A * C;
}
C = C + 1;
}
if (A==N)
{
txtPRIMOSN.Text = "SI";
}
else
{
txtPRIMOSN.Text = "NO";
}
}
else
{
MessageBox.Show("ERROR");
}
}

private void btnDETERMINAR2_Click(object sender, EventArgs e)


{
int N, C, D, A;
N = Convert.ToInt32(txtNUMERO3.Text);
if (N>0)
{
C = 1;
A = 0;
do
{
D = N % C;
if (D==0)
{
A = A + C;
}
C = C + 1;
}
while (C<N);
if (A==N)
{
txtPERFECTOSN.Text = "SI";
}
else
{
txtPERFECTOSN.Text = "NO";
}
}
else
{
MessageBox.Show("ERROR");
}
}

private void label10_Click(object sender, EventArgs e)


{

private void btnCALCULAR_Click(object sender, EventArgs e)


{
int N1, N2, D1, D2, C;
N1 = Convert.ToInt32(txt1ERNUM.Text);
N2 = Convert.ToInt32(txt2DONUM.Text);
if (N1>0 && N2>0)
{
listBox2.Items.Clear();
C = 1;
while (C <= N1 && C <= N2)
{
D1 = N1 % C;
D2 = N2 % C;
if (D1 == 0 && D2 == 0)
{
listBox2.Items.Add(C);
}
C = C + 1;
}
}
else
{
MessageBox.Show("ERROR");
}
}
}
}

You might also like