mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 08:25:20 +08:00
n+1 to include n in range
Python's range stop right before n, which means factL never returns the correct result. Closes: https://github.com/ruby/ruby/pull/1982
This commit is contained in:
1 parent
253da5b219
commit
6bb3618f28
1 file changed
+1
-1
@@ -3,7 +3,7 @@
|
||||
|
||||
def factL(n):
|
||||
r = 1
|
||||
for x in range(2, n):
|
||||
for x in range(2, n+1):
|
||||
r *= x
|
||||
return r
|
||||
|
||||
|
||||
Reference in new issue
Block a user