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

math: add tau constant, add factorial function

This commit is contained in:
Parth Paradkar 2019-06-27 22:46:02 +05:30 committed by Alexander Medvednikov
parent 08c37121e8
commit 5651ba5342

View File

@ -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
}