Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,24 @@
function invmod {
typeset -i a=$1 n=$2
if (( n < 0 )); then (( n = -n )); fi
if (( a < 0 )); then (( a = n - (-a) % n )); fi
typeset -i t=0 nt=1 r=n nr q tmp
(( nr = a % n ))
while (( nr )); do
(( q = r/nr ))
(( tmp = nt ))
(( nt = t - q*nt ))
(( t = tmp ))
(( tmp = nr ))
(( nr = r - q*nr ))
(( r = tmp ))
done
if (( r > 1 )); then
return 1
fi
while (( t < 0 )); do (( t += n )); done
printf '%s\n' "$t"
}
invmod 42 2017