Skip to content

Instantly share code, notes, and snippets.

@Techgokul
Created December 2, 2017 09:23
Show Gist options
  • Save Techgokul/b42c55870da2c69abaa1d6f28304b8cf to your computer and use it in GitHub Desktop.
Save Techgokul/b42c55870da2c69abaa1d6f28304b8cf to your computer and use it in GitHub Desktop.
Find The LCM of Two Integers
#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