+1 vote

GDScript has a function for square roots and cubed roots. But how, in GDScript would you figure out 4√x or 5√x ?

Godot version 3.5.1
in Engine by (93 points)

1 Answer

+3 votes
Best answer

This should work although n and s would have to be floats not integers

func root(n, s):
    print(pow(n, (1/s)))
by (3,321 points)
selected by

I think you'll get more expected results if you force float division. Just this should work...

pow(n, 1.0/s)

Yes good point! I should have thought of that!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.