-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAsalmi.java
More file actions
28 lines (25 loc) · 771 Bytes
/
Asalmi.java
File metadata and controls
28 lines (25 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.company;
import java.util.Scanner;
public class Asalmi {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Lütfen Bir Sayı Giriniz: ");
int sayi = scanner.nextInt();
if(sayi > 1){
boolean asalmi = true;
for(int i = 2; i < sayi; i++){
if(sayi%i == 0){
asalmi = false;
break;
}
}
if(asalmi){
System.out.println("Girilen Sayı Asaldır");
}else{
System.out.println("Girilen Sayı Asal Değildir");
}
}else{
System.out.println("Asallıktan Söz Edilemez");
}
}
}