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
Multiplying powers
Moderator: General Moderators
- johnperkins21
- Forum Contributor
- Posts: 140
- Joined: Mon Oct 27, 2003 4:57 pm
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
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.
Code: Select all
<?php
$answer = 10;
$x = 1;
while ($x <= 10) {
$answer = $answer * 10;
$x++;
}
?>