matty Posted June 3, 2007 Share Posted June 3, 2007 How would i do a sum that includes a cube root?? For example 125 cube rooted? I tried $sum = 3^125; But nothing... Can you guys help? Thanks, Matt Quote Link to comment https://forums.phpfreaks.com/topic/54108-solved-cube-rooting/ Share on other sites More sharing options...
Lumio Posted June 3, 2007 Share Posted June 3, 2007 <?php $num = 3; $n = 3; $p = 125; for($i=2; $i<=p; $i++) $num *= $n; echo $n; ?> Quote Link to comment https://forums.phpfreaks.com/topic/54108-solved-cube-rooting/#findComment-267494 Share on other sites More sharing options...
matty Posted June 3, 2007 Author Share Posted June 3, 2007 It doesn't work... It gives me 3 when I'm looking for 5. EDIT - In fact it gives me three for any number. Quote Link to comment https://forums.phpfreaks.com/topic/54108-solved-cube-rooting/#findComment-267497 Share on other sites More sharing options...
DLR Posted June 3, 2007 Share Posted June 3, 2007 Hi there, Cube root is just a number multiplied by itself 3 times, so possibly $answer = $num*$num*$num; would do? David Quote Link to comment https://forums.phpfreaks.com/topic/54108-solved-cube-rooting/#findComment-267502 Share on other sites More sharing options...
matty Posted June 3, 2007 Author Share Posted June 3, 2007 I know, but I want to get the cube root from 125 which is 5, but say I don't know that.. what you posted would work if i wanted to get the cube of 5 but not the cube root from 125... If you get me? Quote Link to comment https://forums.phpfreaks.com/topic/54108-solved-cube-rooting/#findComment-267504 Share on other sites More sharing options...
matty Posted June 3, 2007 Author Share Posted June 3, 2007 Never mind... sorted it myself now.. This was what i was looking for $sum = pow(125, 1/3); Quote Link to comment https://forums.phpfreaks.com/topic/54108-solved-cube-rooting/#findComment-267505 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.