Loading ...
Sorry, an error occurred while loading the content.

Re: [JavaScript] Help -- PHP Problem

Expand Messages
  • Felipe Valdez
    ... n E i to the k 0 i cant find the right symbol for that equation, sorry = 1 ^ k+2 ^ k+3 ^ k+ ...+ (n-1) ^ k+ n ^ k wich in your case: n=3 k=2 1 ^2+2 ^2+3
    Message 1 of 2 , Dec 10, 2004
    • 0 Attachment
      > I am a beginner of the PHP ,somebody can help me to solve the
      > problem,Please.Thanks.
      >
      > This is the PHP coding,if "n is 3" ,"k is 2".After calculation, the
      > answer is 14 ! I don't understand why the answer is "14".
      >
      > <!-- Equation.php -->
      > <html>
      > <head>
      > <title>Result of Equation</title></head>
      >
      > <?php
      > function calPower($n, $k){
      > $result=1;
      > for ($x=1;$x<=$k;$x++){
      > $result=$result*$n;
      > }
      > return $result;
      > } // calPower
      >
      > function calEquation($n, $k){
      > $answer=0;
      > for ($x=1;$x<=$n;$x++){
      > $answer=$answer+calPower($x,$k);
      > }
      > return $answer;
      > } // calEquation
      >
      >
      > ?>
      >
      > <body>
      > <?php
      > echo "<font size=\"5\" face=\"Courier\">You have entered
      > $thebase as n and $thepower
      > as k.</font><BR><BR>";
      >
      > echo "<font size=\"5\" face=\"Courier\">After calculation,
      > the answer is " .calEquation($thebase, $thepower) . " !</font>";
      >
      > ?>
      > </body>
      > </html>



      n
      E i to the k
      0
      i cant find the right symbol for that equation, sorry

      =>
      1 ^ k+2 ^ k+3 ^ k+ ...+ (n-1) ^ k+ n ^ k

      wich in your case:
      n=3
      k=2
      1 ^2+2 ^2+3 ^2 == 1+4+9 ==14

      x^y stands for " x multiplied by x y times"


      --
      /fel
    Your message has been successfully submitted and would be delivered to recipients shortly.