Re:Why I Use Perl: Reliability
by colomon on Tuesday May 29, 2012 @04:59PM
(#4039855)
Based on the examples, I presume xrange(x) is every integer up to but not including x. ie 1..^$x in Perl 6, don't recall if that's the Perl 5 syntax or not.
[ Parent
| on HN ]
> Based on the examples, I presume xrange(x) is every integer up to but not including x
Yes. That makes my Python example incorrect(should be xrange(2, num + 1))
> 1..^$x in Perl 6, don't recall if that's the Perl 5 syntax or not.
Perl 5 doesn have 1..^$x. I have always used 1..($n - 1) where I needed it - don't know if there is a better alternative.
> Yes. That makes my Python example incorrect(should be xrange(2, num + 1))
Or just xrange(num) and then, as in my original code, output *= num + 1. :-)
> Or just xrange(num) and then, as in my original code, output *= num + 1. :-)
HN ate your asterisk(it uses asterisk to mark italics), or something wrong with my chrome app for HN. In your post, I saw:
def Factorial(x): output = 1 for i in xrange(x): output = (i + 1) return output