Smallest Multiple of M
The program must accept two integers M and N as the input. Then the program must print the smallest multiple of M which is also divisible by M+N as the output.
Boundary Condition(s):
1 <= M, N <= 10^5
Input Format:
The first line contains the values of M and N separated by a space.
Output Format:
The first line contains the smallest multiple of M which is also divisible by M+N.
Example Input/Output 1:
Input:
6 14
Output:
60
Explanation:
The sum of 6 and 14 is 20.
The smallest multiple of 6 which is divisible by 20 is 60.
Hence the output is 60
Example Input/Output 2:
Input:
12 5
Output:
204
program in C:
#include<stdio.h>
int main()
{int a,b;
scanf("%d %d",&a,&b);
int c=a+b,d=a;
for(int i=1;i>=1;i++)
{d=a*i;
if(d%c==0)
{ printf("%d",d);
break;}
}
}
Comments
Post a Comment