using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace checkNumbers
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int startVal = Int32.Parse( textBox1.Text);
int endVal = Int32.Parse(textBox2.Text);
if (radioButton1.Checked)
{
listBox1.Items.Clear();
for (int i = startVal; i <= endVal; i++)
{
if (i % 2 == 0)
{
listBox1.Items.Add(i);
}
}
}
if (radioButton2.Checked)
{
listBox1.Items.Clear();
for (int i = startVal; i <= endVal; i++)
{
if (i % 2 == 1)
{
listBox1.Items.Add(i);
}
}
}
if (radioButton3.Checked)
{
int i, j;
listBox1.Items.Clear();
for (i = startVal; i <= endVal; i++)
{
for (j = 2; j <= i; j++)
{
if (i % j == 0)
{
break;
}
}
if (j == i)
{
listBox1.Items.Add(i);
}
}
}
if (radioButton4.Checked)
{
int i, j;
listBox1.Items.Clear();
for (i = startVal; i <= endVal; i++)
{
for (j = 2; j < i; j++)
{
if (i % j == 0)
{
listBox1.Items.Add(i);
break;
}
}
}
}
}
}
}
0 comments :