-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmukemmelSayi.java
More file actions
45 lines (28 loc) · 836 Bytes
/
mukemmelSayi.java
File metadata and controls
45 lines (28 loc) · 836 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package projeler2;
import java.util.Scanner;
public class mukemmelSayi {
public static void main(String[] args) {
/*
SORU 19:
MUKEMMEL SAYİ KENDİSİ HARİC BOLENLERİNİN TOPLAMI KENDİSİNE EŞİT OLAN SAYİLARA MUKEMMEL SAYİ DENİR.
ÖRNEK :
6 = 3 + 2 + 1
28 = 14 + 7 + 4 + 2 + 1
*/
Scanner input = new Scanner(System.in);
System.out.print("sayi giriniz : ");
int sayi = input.nextInt();
int bolenlerToplami = 0;
for (int counter = sayi-1; counter > 0; counter--) {
if (sayi % counter == 0) {
bolenlerToplami+=counter;
}
}
if (bolenlerToplami == sayi) {
System.out.println(sayi+" MUKEMMEL SAYIDIR.");
}
else {
System.out.println("MUKEMMEL SAYI DEGILDIR.");
}
}
}