Last active
August 2, 2016 16:34
-
-
Save nerzid/59ca0e8b330380de26c0de9a8d449abe to your computer and use it in GitHub Desktop.
YouTube Nerzid Kanalı | Java 101 Video Serisi Bölüm 28 | Asal Sayılar Probleminin Çözümü
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
import java.util.ArrayList; | |
public class AsalSayilar { | |
public static void main(String[] args) { | |
ArrayList<Integer> asal_sayilar = new ArrayList<>(); | |
asal_sayilar.add(2); | |
asal_sayilar.add(3); | |
//i = 13, j = 12 | |
boolean isPrime = true; | |
for (int i = 4; i < 100; i++) { | |
for (int j = i - 1; j > 1; j--) { | |
isPrime = true; | |
if (i % j == 0) { | |
isPrime = false; | |
break; | |
} | |
} | |
if (isPrime) { | |
asal_sayilar.add(i); | |
} | |
} | |
System.out.println(asal_sayilar); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment