You are here

function greatest_common_divisor in Recipe 7.2

Same name and namespace in other branches
  1. 6 recipe.module \greatest_common_divisor()
  2. 7 recipe.module \greatest_common_divisor()

Finds the greatest common divisor of two numbers.

1 call to greatest_common_divisor()
recipe_ingredient_quantity_from_decimal in ./recipe.module
Converts an ingredient's quantity from decimal to fraction.

File

./recipe.module, line 1102
Contains functions for Recipe node CRUD and display.

Code

function greatest_common_divisor($a, $b) {
  while ($b != 0) {
    $remainder = $a % $b;
    $a = $b;
    $b = $remainder;
  }
  return abs($a);
}