Java Euclidean euclideanGCD(final long firstNumerator, final long secondNumerator)

Here you can find the source of euclideanGCD(final long firstNumerator, final long secondNumerator)

Description

euclidean GCD

License

Open Source Community License

Declaration

public static long euclideanGCD(final long firstNumerator, final long secondNumerator) 

Method Source Code

//package com.java2s;
/******************************************************************************
 *                                                                             *
 *  Copyright: (c) Syncleus, Inc.                                              *
 *                                                                             *
 *  You may redistribute and modify this source code under the terms and       *
 *  conditions of the Open Source Community License - Type C version 1.0       *
 *  or any later version as published by Syncleus, Inc. at www.syncleus.com.   *
 *  There should be a copy of the license included with this file. If a copy   *
 *  of the license is not included you are granted no right to distribute or   *
 *  otherwise use this file except through a legal and valid license. You      *
 *  should also contact Syncleus, Inc. at the information below if you cannot  *
 *  find a license:                                                            *
 *                                                                             *
 *  Syncleus, Inc.                                                             *
 *  2604 South 12th Street                                                     *
 *  Philadelphia, PA 19148                                                     *
 *                                                                             *
 ******************************************************************************/

public class Main {
    public static long euclideanGCD(final long firstNumerator, final long secondNumerator) {
        long firstEuclidean = firstNumerator;
        long secondEuclidean = secondNumerator;
        while (firstEuclidean != 0) {
            final long tempEuclidean = firstEuclidean;
            firstEuclidean = secondEuclidean % firstEuclidean;
            secondEuclidean = tempEuclidean;
        }/*from w  w w. j a  v a  2 s.c o  m*/
        return Math.abs(secondEuclidean);
    }
}

Related

  1. euclideanGcd(long a, long b)
  2. euclideanLength(double[] vector)
  3. euclideanMod(final float x, final float y)
  4. euclideanNorm(float vector[])