// Asal Sayilari Bul | Ali AKYILDIRIM | www.aliakyildirim.com
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
// Asal Sayilari Bul | Ali AKYILDIRIM | www.aliakyildirim.com
namespace AsalSayilaiiBul
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
txtSayi.Focus();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
int sayi = Convert.ToInt32(txtSayi.Text);
for (int i = 2; i
{
bool asalmi = true;
for (int j = 2; j
{
if (i % j == 0)
{
asalmi = false;
break;
}
}
if (asalmi)
{
listBox1.Items.Add(i);
button1.Enabled = false;
btnYenile.Enabled = true;
txtSayi.Focus();
lblAdet.Text = "’1’ ile " + "’" + txtSayi.Text.ToString() + "’" + " Arasinda;\n" +
listBox1.Items.Count.ToString() + " Tane ASAL Sayi Vardir";
txtSayi.Enabled = false;
}
}
}
catch (Exception)
{
MessageBox.Show("Sayisal Bir Deger Girmediniz..!", "Bilgi | www.aliakyildirim.com");
txtSayi.Focus();
}
}
private void Form1_Load(object sender, EventArgs e)
{
btnYenile.Enabled = false;
txtSayi.Focus();
}
private void btnYenile_Click(object sender, EventArgs e)
{
button1.Enabled = true;
btnYenile.Enabled = false;
listBox1.Items.Clear();
txtSayi.Clear();
lblAdet.Text = string.Empty;
txtSayi.Enabled = true;
txtSayi.Focus();
}
private void gbAliAKYILDIRIM_Enter(object sender, EventArgs e)
{
txtSayi.Focus();
}
}
}
// Asal Sayilari Bul | Ali AKYILDIRIM | www.aliakyildirim.com