How to find cube root in Ruby

2 Answers

0 votes
n = 16

puts Math.cbrt(n)




# run:
# 
# 2.5198420997897464
#

 



answered Mar 31, 2021 by avibootz
0 votes
n = 16
 
puts Math.exp(Math.log(n) / 3.0)
 
 
 
 
# run:
# 
# 2.519842099789746
#

 



answered Mar 31, 2021 by avibootz
...