-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp-6-25.c
More file actions
47 lines (40 loc) · 816 Bytes
/
exp-6-25.c
File metadata and controls
47 lines (40 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*************************************************************************
> File Name: exp-6-25.c
> Author: xiaoxiaoh
> Mail: xiaoxxhao@gmail.com
> Created Time: Tue Jul 11 10:13:25 2017
************************************************************************/
/*
* Write a C program to find LCM of two numbers
*
* Example
*
* Input
* Input number1: 12
* Input number2: 30
*
* Output
* LCM = 60
*
*/
#include <stdio.h>
int main()
{
int i, num1, num2, max, lcm=1;
//Read two numbers from user
printf("Enter two number one by one: ");
scanf("%d%d", &num1, &num2);
max = (num1 < num2) ? num1: num2;
i = max;
while(1)
{
if((i%num1 == 0) && (i%num2 == 0))
{
lcm = i;
break;
}
i += max;
}
printf("The LCM of %d and %d is %d\n", num1, num2, lcm);
return 0;
}