View Code of Problem 59

#include<iostream>

using namespace std;
int main()
{
	int a,b,max,min,m=0,s=0;
	cin>>a>>b;
	if(a>b)
	{
		max=a;
		min=b;
	}else{
		max=b;
		min=a;
	}
	
	for(int i=max;;i++)
	{
		if(i%a==0&&i%b==0)
		{
			cout<<i<<" ";
			break;
		}		
	}
	for(int j=min;j>=1;j--)
	{
		if(a%j==0&&b%j==0)
		{
			cout<<j;
			break;
			
		}
		
	}
		
	return 0;
}

Double click to view unformatted code.


Back to problem 59