mirror of
https://github.com/Cian-H/dotfiles.git
synced 2026-01-06 00:51:57 +00:00
Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows) and improves grepability with neovim/telescope
This commit is contained in:
15
dot_config/nushell/nu_scripts/modules/recursion/gcd.nu
Normal file
15
dot_config/nushell/nu_scripts/modules/recursion/gcd.nu
Normal file
@@ -0,0 +1,15 @@
|
||||
# Euclid's algorithm for determining greatest common divisor between 2 positive integers
|
||||
# Based on this clear explanation from Rutgers: https://sites.math.rutgers.edu/~greenfie/gs2004/euclid.html
|
||||
|
||||
# Returns the GCD of its 2 arguments
|
||||
def gcd [i1: int, i2: int] -> int {
|
||||
mut a = $i1; mut b = $i2
|
||||
if $a < $b { let tmp = $a; $a = $b; $b = $tmp }
|
||||
let q = $a // $b; let r = $a mod $b
|
||||
if $r == 0 {
|
||||
$b
|
||||
} else {
|
||||
gcd $b $r
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user