Multiplying powers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Linkjames
Forum Commoner
Posts: 90
Joined: Tue Sep 16, 2003 8:39 am

Multiplying powers

Post 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
User avatar
johnperkins21
Forum Contributor
Posts: 140
Joined: Mon Oct 27, 2003 4:57 pm

Post 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.
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

This function might be useful for you :D

pow()
Post Reply