GCD? Coba pake ini aja.
int a = 1000;
int b = 30;
while (b > 0)
{
int c = a % b;
a = b;
b = c;
}
printf("%d\n", a);
KOkon.
2008/1/21 genjuro <[EMAIL PROTECTED]>:
> saya juga mau nanya ttg skrip untuk menghitung FPB apa
> betul kyk gini? (maklum blm di kompile... hehehehe)
>
> #include <iostream>
> using namespace std;
>
> int main() {
> int more, less, mod1, mod2, stepup, equal;
> stepup = 1;
> equal = 1;
> cout << "masukkan angka yang lebih kecil: ";
> cin >> less;
> cout << "masukkan angka yang lebih besar: ";
> cin >> more;
>
> while (stepup <= more) {
> mod1 = less % stepup;
> mod2 = more % stepup;
>
> if (mod1 == 0 && mod2 == 0) {
> if (stepup != more) {
> equal = stepup;
> ++stepup;
>
> else
> ++stepup;
> }
>
> else
> ++stepup;
> }
>
> cout << "FPB untuk " << less << " dan " << more << "
> adalah: ";
> cout << equal;
>
> return 0;
> }
>
> harap koreksiannya ya...
--
Berhenti langganan: [EMAIL PROTECTED]
Arsip dan info: http://linux.or.id/milis