View Code of Problem 59

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	int a,b;
	scanf("%d %d",&a,&b);
	int min,max;
	min = a>b?b:a;
	max = a<b?b:a;
	int i;
	for(i=max;i<=a*b;i++){
		if(i%a==0&&i%b==0){
			printf("%d ",i);
			break;
		}
	} 
	for(i=min;i>=1;i--){
		if(a%i==0&&b%i==0){
			printf("%d",i);
			break;
		}
	} 

	return 0;
}

Double click to view unformatted code.


Back to problem 59