Textbox’a Girilen Sayının Asal Olup Olmadığını İnceleme — Csharp
[code lang=”csharp”]
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;//www.gorselprogramlama.com
namespace Döngüler
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnIncele_Click(object sender, EventArgs e)
{
int sayi = int.Parse(txtSayi.Text);
int yedek = sayi;
for (int i = 2; i <=sayi-1; i++)
{
if (sayi % i == 0)
{
sayi = sayi / i;//www.gorselprogramlama.com
}
}
if (sayi == yedek)
{
lblSonuc.Text = txtSayi.Text + " sayısı Asaldır.";
}
else
{
lblSonuc.Text = txtSayi.Text + " sayısı Asal değildir.";
}
}//www.gorselprogramlama.com
}
}
[/code]

