-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathobeb.java
48 lines (31 loc) · 854 Bytes
/
obeb.java
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
package projeler2;
import java.util.Scanner;
public class obeb {
public static void main(String[] args) {
/*
SORU 29 :
GİRİLEN İKİ SAYİNİN OBEBİNİ ALMA. OBEB ALIRKEN OKLİT YÖNTEMİNİ KULLANDIK.
*/
Scanner input = new Scanner(System.in);
System.out.print("birinci sayi :");
int sayi1 = input.nextInt();
System.out.print("ikinci sayi :");
int sayi2 = input.nextInt();
int kalan = 1;
int buyukSayi =0;
int kucukSayi =0;
if (sayi1 >= sayi2) {
buyukSayi = sayi1;
kucukSayi = sayi2;
} else {
buyukSayi = sayi2;
kucukSayi = sayi1;
}
while (kalan != 0) {
kalan = buyukSayi % kucukSayi;
buyukSayi = kucukSayi;
kucukSayi = kalan;
}
System.out.println("OBEB : "+buyukSayi);
}
}