Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- int gcd_fun(int a,int b)
- {
- if((a=a%b)!=0) {
- gcd_fun(b,a);
- }
- else
- return abs(b);
- }
- int main()
- {
- int temp,a,b,lcm;
- do{
- scanf("%d%d",&a,&b);
- }while(a==0||b==0);
- if(a<b)
- {
- temp=a;
- a=b;
- b=temp;
- }
- lcm=a*b/gcd_fun(a,b);
- printf("%d %d",gcd_fun(a,b),lcm);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement