FPB (Faktor Persekutuan Terbesar) adalah bilangan bulat positif terbesar yang dapat membagi habis Bilangan tersebut.
Contoh kasus
Mencari FPB dari 12 dan 20
- Faktor dari 12 = 1, 2, 3, 4, 6 dan 12
- Faktor dari 20 = 1, 2, 4, 5, 10, dan 20
- FPB dari 12 dan 20 adalah faktor sekutu (sama) yang terbesar adalah 4
package
fpb;
import
java.util.*;
public
class Main {
public static void main(String[] args) {
int a, b,c, r;
Scanner dataInput = new
Scanner(System.in);
System.out.print("Masukkan Nilai
Bilangan I : ");
a = dataInput.nextInt();
System.out.print("Masukkan Nilai
Bilangan II : ");
b = dataInput.nextInt();
System.out.print("Masukkan Nilai
Bilangan III : ");
c = dataInput.nextInt();
System.out.println();
r = a % b % c;
do{
a = b;
b = c;
c = r;
r = a % b % c;
}
while (r != 0);
System.out.println("Maka FPB dari
3 Bilangan : "+c);
}
}
Bagaimana? Susahkah? Tentu tidak Bukan :)
Selamat Mencoba
Your Affiliate Profit Machine is ready -
ReplyDeleteAnd making money online using it is as simple as 1---2---3!
Here's how it works...
STEP 1. Tell the system what affiliate products the system will push
STEP 2. Add some PUSH BUTTON traffic (it LITERALLY takes 2 minutes)
STEP 3. See how the system grow your list and sell your affiliate products all on it's own!
Are you ready to make money automatically?
You can test-drive the system for yourself risk free...