Re: please i need explanation

Discussion in 'Python' started by Vincent Vande Vyvre, Jan 11, 2013.

  1. Le 11/01/13 16:35, a écrit :
    > def factorial(n):
    > if n<2:
    > return 1
    > f = 1
    > while n>= 2:
    > f *= n
    > f -= 1
    > return f
    >
    >
    >

    I guess you mean:
    f = 1
    while n>= 2:
    f *= n
    n -= 1
    return f

    Try it.



    --
    Vincent V.V.
    Oqapy <https://launchpad.net/oqapy> . Qarte
    <https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager>
    Vincent Vande Vyvre, Jan 11, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    109
    Walter Hurry
    Jan 13, 2013
  2. K. Elo

    Re: please i need explanation

    K. Elo, Jan 11, 2013, in forum: Python
    Replies:
    0
    Views:
    115
    K. Elo
    Jan 11, 2013
  3. Karim

    Re: please i need explanation

    Karim, Jan 11, 2013, in forum: Python
    Replies:
    0
    Views:
    113
    Karim
    Jan 11, 2013
  4. Jussi Piitulainen

    Re: please i need explanation

    Jussi Piitulainen, Jan 11, 2013, in forum: Python
    Replies:
    2
    Views:
    107
  5. Karim

    Re: please i need explanation

    Karim, Jan 11, 2013, in forum: Python
    Replies:
    0
    Views:
    93
    Karim
    Jan 11, 2013
Loading...

Share This Page