From: Florian Frank Date: 2005-12-24T04:56:43+09:00 Subject: Re: Why not Python? (No, no, I am not a spy) Jeff Wood wrote: >heh, darn, bug there ... > ># yes assumptions about positive integer numbers... ># factorial of 0 is undefined ... > ># complete recursive: > >def factorial( x ) > return 1 if x < 1 > > return 1 if x <= 1 > x * factorial( x - 1 ) >end > ># tail-recursive: > >def factorial( x, sum = 1 ) > return 1 if x < 1 > > return sum if x <= 1 > factorial( ( x - 1 ), ( sum * x ) ) >end > ># iterative: > >def factorial( x ) > sum = 1 > for i in (1..x).to_a > > for i in 1..x > sum *= i > end >end > > And why do you call your products "sum"? -- Florian Frank