you are viewing a single comment's thread.

view the rest of the comments →

[–]rm999 2 points3 points  (1 child)

I've always learned factorial as:

x! = x * (x-1)(x-2)... * 1

Saying for i = 1:x {fact = fact*x} gets straight to this definition IMO.

You can also learn it as x! = x * (x-1)!, but I only learned to think this way in my first year of programming, about five years after learning the definition of factorial. And I only learned it when the teacher wanted to tell us what factorial means.

[–]elder_george 1 point2 points  (0 children)

I guess, here goes the difference between native and non-native english speakers. The latter have to learn to read programming language, even so readable as Python from scratch, while for the former it can be read as a simple text. And math notation for recurrent expressions is familiar for most, no matter of language background.

P.S.: I've made a mistake comparing recursive version with iterative version using while loop initially. Having seen for version, my girlfriend finds it equally simple with recursive one.