Created
December 21, 2019 08:29
-
-
Save ouzdev/c7b7183286a36dc0acf11eeaf241b5c5 to your computer and use it in GitHub Desktop.
Asal sayıların metodla bulunması.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 asal_sayi_metod | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
public void Bul(ListBox lst,int min , int max) | |
{ | |
bool durum = false; | |
int kontrol = 0; | |
for (int i = min; i < max; i++) | |
{ | |
for (int j =2; j < i; j++) | |
{ | |
if (i%j==0) | |
{ | |
kontrol = 1; | |
break; | |
} | |
if (kontrol==1) | |
{ | |
durum = true; | |
if (i!=0) | |
{ | |
lst.Items.Add(i); | |
kontrol = 0; | |
} | |
} | |
else | |
{ | |
durum = false; | |
} | |
} | |
} | |
} | |
private void btn_bul_Click(object sender, EventArgs e) | |
{ | |
Bul(listBox1, 2, 100); | |
} | |
private void btn_bul_2_Click(object sender, EventArgs e) | |
{ | |
Bul(listBox2, 100, 500); | |
} | |
private void btn_bul_3_Click(object sender, EventArgs e) | |
{ | |
Bul(listBox3, 500, 1000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment