myusufs

fpb

Feb 25th, 2021
550
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <conio.h>
  3. int main(){
  4.     int i,x,y,kecil,xmod,ymod,fpb;
  5.     printf("Mencari FPB (Faktor Persekutuan Terbasar)\n");
  6.     printf("Masukkan bilangan bulat pertama : "); scanf("%d",&x);
  7.     printf("Masukkan bilangan bulat kedua   : "); scanf("%d",&y);
  8.    
  9.     if(x>y) //menentukan bilangan yg lebih kecil
  10.         kecil=y;
  11.     else
  12.         kecil=x;
  13.  
  14.     for(i=1;i<=kecil;i++){ //melakukan perulangan pembagian sampai di dapatkan modulus 0 dari tiap bilangan
  15.         xmod=x%i;
  16.         ymod=y%i;
  17.         if(xmod==0 && ymod==0)
  18.             fpb=i;
  19.     }
  20.    
  21.     printf("\n\nFPB dari %d dan %d adalah %d\n",x,y,fpb);
  22.     getch();
  23. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×