1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

added factorial

This commit is contained in:
Kamil 2021-10-24 18:23:04 +00:00 committed by GitHub
parent 4a28cab81d
commit 38a8f30267
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,6 +22,11 @@ def delta [ a: number, b: number, c: number ] {
( $b ** 2 ) - ( 4 * $a * $c)
}
#factorial of a given number, works fine only for n<21 (integer range)
def fact [num:number] {
if $num >= 0 { if $num < 2 {$num} {seq 2 $num | math product} } { echo 'Error: can only calculate non-negative integers'}
}
#TODO:
# -sin, cos, tan table for 0-90 degrees
# -radians to degrees and reversed