Horje
gcd Code Example
gcd
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
gcd
int gcd(int a, int b) {
    while (b) b ^= a ^= b ^= a %= b;
    return a;
}
gcd
static int gcd(int a, int b)
    {
      if (b == 0)
        return a;
      return gcd(b, a % b); 
    }
     
gcd
int gcd(int a,int b) {
	while (a&&b) a>b?a%=b:b%=a;
	return a+b;
}
gcd
import math

a = 10
b = 8
answer = math.gcd(10, 8)
print(answer)
GCD
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+")");
    }
}





Cpp

Related
reverse sort a vector Code Example reverse sort a vector Code Example
ranged based for loop c++ Code Example ranged based for loop c++ Code Example
Explicit conversion casting Code Example Explicit conversion casting Code Example
visual studio getline not working Code Example visual studio getline not working Code Example
take single digit integer input in c++ Code Example take single digit integer input in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8