Factorial with multiple entries in Python

2

I need to write a program in the Python language that reads multiple entries, and that, upon receipt of the "-1" entry, the program prints the factorials of their entry numbers.

Detail: I need to use the while loop function, since it is part of the current subject I study. I'm writing this way:

while True:
    n = int(raw_input())
    if n >= 0:
        continue
    if n == -1:
        break
    numeroCalc = n
    fatorial = 1
    while numeroCalc > 0:
        fatorial = fatorial * numeroCalc
        numeroCalc = numeroCalc - 1
    print fatorial

But it is not working.

    
asked by anonymous 18.03.2016 / 23:27

1 answer

3

For what you said you want, it should be +/- so the code

numb = "\n"

while True:
    n = int(raw_input())
    if n == -1:
        break
    numeroCalc = n
    fatorial = 1
    while numeroCalc > 0:
        fatorial = fatorial * numeroCalc
        numeroCalc = numeroCalc - 1
    numb = numb+str(fatorial)+"\n"

print numb
    
19.03.2016 / 00:05