math.sk

Created by Shroob

Other available versions. Ordered by newest to oldest versions:

Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.




function Math_IsFinite(n: number) :: boolean: # what do ya think this is
	return false if {_n} is infinity value
	return true

function Math_Sign(n: number) :: number: # returns 0 if n = 0, returns 1 if {_n} is positive, returns -1 if {_n} is negative
	return -1 if {_n} < 0
	return 1 if {_n} > 0
	return 0

function Math_Factorial(n: number) :: number: # stirling's approximation
	if {_n} < 0: # this complex bro pretty sure it's not even a real number at this point
		return NaN value
	return 1 if {_n} = 0
	if {_n} < 5: # stirling's approximation for low numbers is bad
		return Math_Factorial({_n}+5)/({_n}+5)/({_n}+4)/({_n}+3)/({_n}+2)/({_n}+1)
	set {_r} to ((2*Math_Pi()*{_n})^0.5*(({_n}/Math_e())^{_n}))^1 # ^1 to force a double
	set {_n2} to {_n}
	add 1 to {_r2} # a LOT of math
	add 1/(12*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add 1/(288*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add -139/(51840*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add -571/(2488320*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add 163879/(209018880*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add 5246819/(75246796800*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add -534703531/(902961561600*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add -4483131259/(86684309913600*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add 432261921612371/(514904800886784000*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add 6232523202521089/(86504006548979712000*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add -25834629665134204969/(13494625021640835072000*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add -1579029138854919086429/(9716130015581401251840000*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add 746590869962651602203151/(9716130015581401251840000*{_n2}) to {_r2}
	set {_n2} to {_n2}*{_n}
	add 1511513601028097903631961/(116593560186976815022080000*{_n2}) to {_r2}
	return {_r}*{_r2}
	
function Math_Pi(n: number = 1) :: number: # returns pi * n
	return 3.141592653589793238*{_n}
function Math_e(n: number = 1) :: number: # returns e * n
	return 2.718281828459045235*{_n}