İşte program kodları ;
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 AsalSayıBulma
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Metot başlangıcı
static string asal(int sayi)
{
bool durum = false;
int sayac = 2;
while (sayac < sayi)
{
if ((sayi % sayac) == 0)
{
durum = true;
break;
}
sayac++;
}
if (durum == true)
return "Sayısı Asal Sayı Değil";
else
return "Sayısı Asal";
}
//Metot sonu
private void button1_Click(object sender, EventArgs e)
{
for (int i = 2; i <= 100; i++)
{
listBox1.Items.Add(" " + i + "\t" + asal(i));
}
}
}
}
Programımızın ekran görüntüsü aşağıdaki gibi olacaktır. İsteyen arkadaşlar kendi tasarımlarını yapabilirler...
Hiç yorum yok:
Yorum Gönder