This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gcd(a, b) | |
local x = a; local y = b | |
repeat | |
if x > y then | |
x = math.fmod(x, y) | |
else | |
y = math.fmod(y, x) | |
end | |
until x == 0 or y == 0 | |
return x + y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%define groovy_root_dir /usr/share | |
Name: groovy | |
Version: 2.2.2 | |
Release: 1%{?dist} | |
License: See: http://groovy.codehaus.org/license.html | |
BuildRoot: %{_tmppath}/%{name}-%{version}-build | |
Group: Development/Languages/Groovy | |
Summary: Contains the base system for executing groovy scripts. | |
Source: http://dist.codehaus.org/groovy/distributions/groovy-binary-%{version}.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdexcept> | |
template<typename T> T modulo(T dividend, T divisor) { | |
if (divisor == static_cast<T>(0)) // division by zero is not allowed | |
throw std::domain_error("division by zero"); | |
if (dividend < static_cast<T>(0)) // dividend is negative | |
return -((-dividend) % (-divisor)); | |
else // dividend is non-negative | |
return dividend % divisor; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\ This implements Euclidean algorithm in Forth | |
: gcd ( X Y ) | |
2dup <= if swap ( Y X ) then | |
( X Y ) | |
begin | |
tuck ( Y X Y ) | |
mod ( Y Z ) | |
dup ( Y Z Z ) | |
0= until ( Y Z ) | |
( Y 0 ) |
OlderNewer