Wednesday, March 16, 2016

Code for LCD

#include<bits/stdc++.h>
using namespace std;


int main()
{
    int a,b,c;
    cin>>a>>b;
    int e=a, f=b;

    while(b!=0)
    {
        int t=b;
        b=a%b;
        a=t;
    }

    c=(e*f)/a;
    cout<<c<<endl;

    return 0;
}



with function:

//Bismillah-hir-rah-ma-nir-rahim(in the name of Allah)
//Thinker: Arafat Kamal Tamzid(Sylhet Engineering College)

#include<bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
    int t,e,f;
    e=a,f=b;
    while(b!=0)
    {
        t=b;
        b=a%b;
        a=t;
    }
    int lcd=(e*f)/a;
    return lcd;
}

int main()
{
    int a,b,c;
    cin>>a>>b;
     c=gcd(a,b);
    cout<<c<<endl;

    return 0;
}


No comments:

Post a Comment

Speedup Android Studio

Go to Help ->Edit Custom VM Options, and chnge this 4 setting. After that close your Android Studio. This settings are for 8gb of ram pc...