-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbolSayi.java
More file actions
49 lines (30 loc) · 1.03 KB
/
bolSayi.java
File metadata and controls
49 lines (30 loc) · 1.03 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package projeler2;
import java.util.Scanner;
public class bolSayi {
public static void main(String[] args) {
/*
SORU 25 :
KLAVYEDEN GİRİLEN SAYININ BOL SAYI OLUP OLMADIGINI BULMA
BOL SAYI : KENDİSİ HARİC BOLENLERİN TOPLAMI KENDİSİNDEN BÜYÜK İSE BOL SAYIDIR.
ORNEK :
12'NİN BOLENLERİ 6,4,3,2,1
12 < 6+4+3+2+1
BOYLECE 12 BOL BİR SAYIDIR
*/
Scanner input = new Scanner(System.in);
System.out.print("sayi giriniz : ");
int isBol = input.nextInt();
int bolenlerToplami = 0;
for (int bolenler = isBol - 1; bolenler > 0; bolenler--) {
if (isBol % bolenler == 0) {
bolenlerToplami += bolenler;
}
}
if (isBol < bolenlerToplami ) {
System.out.println(isBol + " bol bir sayidir.");
}
else {
System.out.println(isBol + " bol bir sayi degildir.");
}
}
}