sort correctly the added functions

This commit is contained in:
Kaputchino 2022-05-25 19:02:29 +02:00 committed by GitHub
parent 7d7033cd61
commit 7ce2d39b93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,27 +151,7 @@ func Comb(n, r)
{ {
return Perm(n ,r) / Fac(r) return Perm(n ,r) / Fac(r)
} }
//return the number of permutation
func Perm(n, r)
{
if n < 0
{
ZS.System.PrintLine("n muss be superior or equal to 0")
return -1
}
if r < 0
{
ZS.System.PrintLine("r muss be superior or equal to 0")
return -1
}
if r > n
{
ZS.System.PrintLine("r muss be inferor or equal to n")
return -1
}
return Fac(n) / Fac(n - r)
}
//return the factorial of a number //return the factorial of a number
func Fac(x) func Fac(x)
@ -201,5 +181,28 @@ func TaylorExp(x)
} }
return sum return sum
} }
//return the number of permutation
func Perm(n, r)
{
if n < 0
{
ZS.System.PrintLine("n muss be superior or equal to 0")
return -1
}
if r < 0
{
ZS.System.PrintLine("r muss be superior or equal to 0")
return -1
}
if r > n
{
ZS.System.PrintLine("r muss be inferor or equal to n")
return -1
}
return Fac(n) / Fac(n - r)
}
)" )"
; ;