aboutsummaryrefslogblamecommitdiff
path: root/bc_funcs/std.bc
blob: 6bc58b1c23cd763eac5443a1d0370a791a77b2d9 (plain) (tree)
1
2
3
4
5




                       


















                                              
define abs(x) {
	if (x < 0)
		x *= -1
	return x
}

define fact(x) {
    auto r

    if (x < 0) {
        print "Error: Negative factorial\n"
        return 0
    }

    if (x % 1 != 0) {
        print "Error: Non-integer factorial\n"
        return 0
    }

    r = 1
    for (i = 2; i <= x; i++)
        r *= i
    return r
}