Page 1 of 1

Multiplying powers

Posted: Tue Dec 02, 2003 2:03 pm
by Linkjames
I need to create a script that will calculate 1*10(To the power of 10) but have no idea how to feed the calculation into PHP without doing

$answer1 = '10';
$answer2 = $answer1 * 10;
$answer3 = $answer2 * 10;

etc etc. Any ideas?
cheers guys

Posted: Tue Dec 02, 2003 2:09 pm
by johnperkins21
I'm still new to php so I'm not sure of the exact code structure, but I would set up a while loop to do this

Code: Select all

<?php
$answer = 10;
$x = 1;
while ($x <= 10) {
$answer = $answer * 10;
$x++;
}
?>
I'm pretty sure that's what you're looking for. Again, my apologies for not knowing the code, but that should get you started. Good luck.

Posted: Tue Dec 02, 2003 3:52 pm
by DuFF
This function might be useful for you :D

pow()