Rishab owns a rectangular plot of land . Due to certain financial problems , he wishes to sell some parts of his plot. Rishab finds out that square shaped plots sell better than rectangular ones . With this in mind, he decides to divide his plot into minimum possible square plots so that he can get maximum profit . All the square plots have the same dimension. Given the dimensions of his plot , Write a Program to calculate the minimum number of square plots. Input The first line of input consists of two integers L and B which denotes the length and breadth of the rectangular plot. Output Output is a single line which denotes the minimum number of square plots that can be formed Test Case 1 Input (stdin) 4 6 Expected Output 6 Test Case 2 Input (stdin) 10 15 Expected Output 6
#include<stdio.h>
int main()
{
long int i,j,m,n,x,a,b;
for(i=1;i<=1;i++)
{
scanf("%ld %ld",&m,&n);
for(j=1; j<=m&&j<=n; j++)
{
if(m%j==0 && n%j==0)
{
x=j;
}
}
a=m/x;
b=n/x;
printf("%ld \n",(a*b));
}
return 0;
}