18 Temmuz 2008 Cuma

C# 0-1000 Arası Asal Sayılar


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;
namespace AsalSaylar2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnEkle_Click(object sender, EventArgs e)
{
for (int i = 2; i < 1000; i++)
{
bool asalmi = true;
for (int j = 2; j < i; j++)
{
if (i % j == 0)
{
asalmi = false;
break;
}
}
if (asalmi)
lbxAsal.Items.Add(i);
}
}
}
}

Hiç yorum yok: