Plz help for this Vectorial

Discussion in 'JavaScript' started by rabi_nawaz, Sep 14, 2012.

  1. #1
    i want when i write 5 or something the result shows like that
    5 x 4 x 3 x 2 x 1 = (Answer) . I thimk this called victorial or vactoria?
    Plz help me i want to write with javascript
     
    rabi_nawaz, Sep 14, 2012 IP
  2. hdewantara

    hdewantara Well-Known Member

    Messages:
    540
    Likes Received:
    47
    Best Answers:
    25
    Trophy Points:
    155
    #2
    Factorial...
    Is it something like below?
    function fact(a){
    var b = a;
    for (var i=a-1; i>0; i--) b *= i;
    return b;
    }
     
    hdewantara, Sep 15, 2012 IP
  3. ronitmathurseo

    ronitmathurseo Member

    Messages:
    98
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #3
    First of all Its not Vatorial its called Factorial. Its an important concept of mathematics and calculation. Now According to your problem you can implement this like
    < language="JavaScript">
    Function fact(var num)
    {
    var b=1;
    for(var i=1;i<=num;i++)
    {
    b=b*i;
    }
    }
    </script>
    you can call this by any event which you know
     
    ronitmathurseo, Sep 17, 2012 IP