Untitled

 avatar
user_7016102
plain_text
a year ago
333 B
5
Indexable
//LAB 8
#include<iostream>
using namespace std;
int gcd(int a, int b)
{
	if(b==0){
		return a;
	}
	else if(b>a)
	{
		return gcd(a,b%a);
	}
	else{
		return gcd(b,a%b);
	}
}
int main()
{
	int a,b;
	cout<<"Enter a and b for GCD : "<<endl;
	cin>>a>>b;
	cout<<"The GCD of ("<<a<<b<< ") is :"<<gcd(a,b);
	return 0;
}
Editor is loading...
Leave a Comment