Created
December 2, 2017 09:23
-
-
Save Techgokul/b42c55870da2c69abaa1d6f28304b8cf to your computer and use it in GitHub Desktop.
Find The LCM of Two Integers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int lcm(int,int); | |
int main() | |
{ | |
int a,b,l; | |
printf("Enter any two postive integers"); | |
scanf("%d%d",&a,&b); | |
if(a>b) | |
l=lcm(a,b); | |
else | |
l=lcm(b,a); | |
printf("LCM of two integers is %d",l); | |
return 0; | |
} | |
int lcm(int a,int b) | |
{ | |
static int temp=1; | |
if(temp%b==0&&temp%a==0) | |
return temp; | |
temp++; | |
lcm(a,b); | |
return temp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment