N root Function?

BlitzMax Forums/BlitzMax Programming/N root Function?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

By the power of maths
SuperStrict

Print "Square root of 4 is " + nroot(4, 2)
Print "Cube root of 27 is " + nroot(27, 3)

Function nroot:Float(number:Float, n:Float)
	Return number ^ (1/n)
End Function


To find the n-th root of a number, raise that number to the power of 1/n. So 4 to the power of (1/2) is 2.