View Code of Problem 59

#include<stdio.h>
int main(){
	int m,n,temp;
	int max,min;
	scanf("%d %d",&m,&n);
	if(m>n)
	temp=n;
	else
	temp=m;
	for(int i=temp;i>=1;i--){
		if(m%i==0&&n%i==0){
		     max=i;
		     break;
	}
    }
	
	if(m>n)
		temp=m;
	else
		temp=n;
	while(1){
		if(temp%m==0&&temp%n==0){
			break; 
		}
		else
		temp++;
	}
	min=temp;
	printf("%d %d",min,max);
}
	

Double click to view unformatted code.


Back to problem 59