2. C++ :
#include <iostream>
#include <string>
using namespace std;
int main()
{ int fpb, x, y;
cout <<"masukan bilangan pertama : ";
cin >> x;
cout <<"masukan bilangan kedua : ";
cin >> y;
fpb =x % y;
while (!(fpb==0))
{
x =y;
y =fpb;
fpb =x % y;
}
cout << y << endl;
return 0;
}
3. JELIOT :
import jeliot.io.*;
public class MyClass {public static void fpb(int x, int y){
int fpb = x % y;
while (!(fpb == 0))
{
x = y;
y = fpb;
fpb = x % y;
}
System.out.print(y);
System.out.print("\n");
}
public static void main() {
int a, b;
System.out.print("masukan bilangan pertama : ");
a=Input.readInt();
System.out.print("masukan bilangan kedua : ");
b=Input.readInt();
fpb(a,b);
// Your algorithm goes here.
}
}
0 komentar:
Posting Komentar