shithub: mc

ref: a9a7d5b32a9423f871311384af6260a3848291d1
dir: /bench/bigfactorial.myr/

View raw version
use std

const N = 600
const main = {
	var i
	for i = 0; i < N; i++
		std.bigfree(bigfact(i))
	;;
}

const bigfact = {n
	var i
	var x, y

	if n == 0
		x = std.mkbigint(1)
	else
		x = std.mkbigint(n)
		for i = n-1; i > 0; i--
			y = std.mkbigint(i)
			std.bigmul(x, y)
			std.bigfree(y)
		;;
	;;
	-> x
}