1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

math: factorial submodule

This commit is contained in:
Ulises Jeremias Cornejo Fandos
2019-12-27 00:08:17 -03:00
committed by Alexander Medvednikov
parent a5b43e1f4d
commit 1277ce22f8
6 changed files with 468 additions and 196 deletions

View File

@@ -181,19 +181,6 @@ pub fn exp2(a f64) f64 {
return C.exp2(a)
}
// factorial calculates the factorial of the provided value.
pub fn factorial(n f64) f64 {
// For a large postive argument (n >= factorials.len) return max_f64
if n >= factorials.len {
return max_f64
}
// Otherwise return n!.
if n == f64(i64(n)) && n >= 0.0 {
return factorials[i64(n)]
}
return gamma(n + 1.0)
}
// floor returns the nearest f64 lower or equal of the provided value.
pub fn floor(a f64) f64 {
return C.floor(a)