[Tutor] How can I make this run right?
rabidpoobear at gmail.com
Mon Aug 15 19:59:38 CEST 2005
> I put in a 4 and expected 24, and instead got 12. It is supposed to give
> not 4*3.
[snip rest of message]
your problem is easy to see...
> >> n = int(raw_input("Number: "))
> >> x = n-1
> >> while 1:
> >> t = n*x
> >> while x > 1:
> >> x -= 1
> >> else:
> >> break
> >> print t
think about it for a *while*...
hint hint *change the while*
hint hint hint *the inner while*
nathan I see that you want to do n!(factorial)
but when you explained it you just said you wanted number!
which is confusing because I think everyone thought you were just excited.
you could always use a recursive function for factorial, IE.
if n > 1:
return factorial(n-1) * n
P.S. Try to fix yours it'll help you. tell me if you get it working
More information about the Tutor