View Code of Problem 59

#include<stdio.h>
int swap(int a,int b){
	int t;
	t=a;
	a=b;
	b=t;
	return;
}
int gcd(int a,int b){
	int t,m;
	t=b%a;
	m=a%t;
	if(m==0)
		return t;
	else
		gcd(b%a,a);
}
void main(){
	int a,b;
	int i,j;
	scanf("%d %d",&a,&b);
	if(a>b)
		swap(a,b);
	for(i=b;i<=a*b;i=i+b)
		if(i%a==0&&i%b==0)
			break;
	j=gcd(a,b);
	printf("%d %d\n",i,j);	
}

Double click to view unformatted code.


Back to problem 59