Here you can find the source of gcd(int firstNumber, int secondNumber)
Parameter | Description |
---|---|
firstNumber | a parameter |
secondNumber | a parameter |
public static int gcd(int firstNumber, int secondNumber)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w ww. j a va 2 s . com*/ * @param firstNumber * @param secondNumber * @return Greatest Common Divisor of given two integers */ public static int gcd(int firstNumber, int secondNumber) { while (firstNumber % secondNumber != 0) { int temp = secondNumber; secondNumber = firstNumber % secondNumber; firstNumber = temp; } return secondNumber; } }