Mostrando entradas con la etiqueta Estructura repetitiva "Mientras". Mostrar todas las entradas
Mostrando entradas con la etiqueta Estructura repetitiva "Mientras". Mostrar todas las entradas

Números Amigos - II



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

        int i, numero1, numero2, s1 = 0, s2 = 0;
        string r = "";
        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
     
        private void button1_Click(object sender, EventArgs e)
        {
            numero1 = int.Parse(textBox1.Text);
            numero2 = int.Parse(textBox2.Text);

            i = 1;
            while (i <= numero1 / 2)
            {
                if (numero1 % i == 0)
                {
                    s1 += i;
                }
                i++;
            }


Inverso de un Número





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

        int d, numero, inverso = 0;

       
        private void button3_Click(object sender, EventArgs e)
            {
            Application.Exit();
            }

        private void button1_Click(object sender, EventArgs e)
            {
            textBox1.Clear();
            textBox2.Clear();
            }


Determinar si es número Primo







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

        //Variables
         int numeroentrada, i;
         bool flag;
         string respuesta = "";

        //Entrada

             private void textBox1_TextChanged(object sender, EventArgs e)
    {
     numeroentrada = int.Parse(textBox1.Text);
     }

       // Proceso y Salida

        private void button1_Click(object sender, EventArgs e)
    {
    flag = true;
    i = 2;
    while (i <= numeroentrada / 2)
            {
             if (numeroentrada % i == 0)
            {
             flag = false;
             break;
             }
               i++;
               }
                       if (flag)
               respuesta = "ES PRIMO";
      else
               respuesta = "NO ES PRIMO";

                       textBox2.Text = respuesta;
                       }