using System;
using System.Windows.Forms;

namespace _7_9
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public static bool IsPrim(int n)
        {
            int k = 2;

            for (int i = 2; i <= n / 2; i++)
                if (n % i == 0)
                    k++;
            
            if (k == 2)
                return true;
            else
                return false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int n = Convert.ToInt32(textBox1.Text);
            
            for (int i = 2; i <= n; i++)
                if (IsPrim(i) == true)
                    listBox1.Items.Add(i);
        }
    }
}