Answers for "gcd c programming"

0

gcd c++

#include<bits/stdc++.h>
using namespace std;
long long UCLN(long long a,long long b)
{
    long long r;
    while (b!=0)
    {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}


int main()
{
    long long a, b;
    cout<< "enter: ";
    cin>> a;
    cout<< "enter: ";
    cin >>b;
    cout<<UCLN(a,b)<<endl;
    return 0;
}
Posted by: Guest on October-03-2021
0

gcd c++

#include<bits/stdc++.h>
using namespace std;
long long UCLN(long long a,long long b)
{
    long long r;
    while (b!=0)
    {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}


int main()
{
    long long a, b;
    cout<< "enter: ";
    cin>> a;
    cout<< "enter: ";
    cin >>b;
    cout<<UCLN(a,b)<<endl;
    return 0;
}
Posted by: Guest on October-03-2021
0

gcd = 1

import java.util.Scanner;
public class   Euclid {
    static public void main(String[] argh){
        System.out.print("Enter two numbers: ");
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int TEMP = 0 ;
        int GCD = 0;
        int max = a>b?a:b;
        int min = a<b?a:b;
        while(min!=0){
            TEMP=(max%min);
            GCD = min ;
            min = TEMP;
        }
        System.out.print("("+GCD+")");
    }
}
Posted by: Guest on July-20-2021
0

gcd = 1

import java.util.Scanner;
public class   Euclid {
    static public void main(String[] argh){
        System.out.print("Enter two numbers: ");
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int TEMP = 0 ;
        int GCD = 0;
        int max = a>b?a:b;
        int min = a<b?a:b;
        while(min!=0){
            TEMP=(max%min);
            GCD = min ;
            min = TEMP;
        }
        System.out.print("("+GCD+")");
    }
}
Posted by: Guest on July-20-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language