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 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; ?> 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. 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 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? 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); Link to comment https://forums.phpfreaks.com/topic/54108-solved-cube-rooting/#findComment-267505 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.