Program menentukan FPB

hai hai.... kali ini aku membagikan source code program untuk menentukan faktor persekutuan terbesar (FPB) dari dua bilangan bulat


#include <iostream>

using namespace std;
int fpb(int x,int y)
{
int hasil,sisabagi;
if(y<=x && x%y==0)
{
return(y);
}
else if(x<y)
{
hasil=fpb(y,x);
return(hasil);
}
else
sisabagi=x%y;
hasil=fpb(y,sisabagi);
return(hasil);
}

main()
{
int hasil,m,n;
cout<<"Masukkan bilangan pertama :";
cin>>m;
cout<<"Masukkan bilangan kedua :";
cin>>n;
hasil=fpb(m,n);
cout<<"\nFPB dari kedua angka tersebut adalah "<<hasil;
//getch ();
}

Share on Google Plus

About Luthfi

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 komentar:

Posting Komentar