How to find fourth root in Ruby

2 Answers

0 votes
n = 16
 
puts Math.exp(Math.log(n) / 4.0)
 
 
 
# run:
# 
# 2.0
#

 



answered Mar 31, 2021 by avibootz
0 votes
n = 16
 
puts n ** (1.0 / 4)
 
 
 
# run:
# 
# 2.0
#

 



answered Mar 31, 2021 by avibootz
...