Yet another, yes another, math related one. I have a form, the user types in
how many numbers they want after the third number they specify. (In other
words, the user enters three numbers, then enters how many MORE number the
user wants to see.) I calculate it as best I can but, very odly, I just get
the second number the user typed in. I don't see how I'm calculating it
wrong. Here's the code:

if($_POST['type'] == "next") // If we need to find the next few numbers....
 {
   // Set up the variables
   $num1 = $_POST['num1'];
   $num2 = $_POST['num2'];
   $num3 = $_POST['num3'];
   // Divide some stuff!
   $divide1 = $num2 / $num1;
   $divide2 = $num3 / $num2;
   if($divide1 == $divide2) // We have a common ratio if this checks out ok
   {
    $r = $divide1;
    echo $r."<br>";
    $number = 1;
    $output = $num3;
    do {
    $output = $output / $r;
    $number++;
    } while($number < $_POST['x']);
    echo $output;
   }
   else
   {
    $r = "None";
   }
 }

For those who don't know, r is the common ratio.

Thanks,
Stephen Craton
http://www.melchior.us

"What is a dreamer that cannot persevere?" -- http://www.melchior.us

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to