diff --git a/math/math.v b/math/math.v index d5e9c6745e..7d071a037d 100644 --- a/math/math.v +++ b/math/math.v @@ -8,6 +8,7 @@ const ( E = 2.71828182845904523536028747135266249775724709369995957496696763 Pi = 3.14159265358979323846264338327950288419716939937510582097494459 Phi = 1.61803398874989484820458683436563811772030917980576286213544862 + Tau = 6.28318530717958647692528676655900576839433879875021164194988918 Sqrt2 = 1.41421356237309504880168872420969807856967187537694807317667974 SqrtE = 1.64872127070012814684865078781416357165377610071014801157507931 @@ -128,3 +129,12 @@ pub fn tanh(a f64) f64 { pub fn trunc(a f64) f64 { return C.trunc(a) } + +pub fn factorial(a int) i64 { + mut prod := 1 + for i:= 0; i < a; i++ { + prod = prod * (i+1) + } + return prod +} +