Do the following snippets of code always return the same output given a positive integer input?
1 2 3 4 5 |
|
1 2 3 4 5 |
|
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The function
xrange(x, y)
is inclusive of x while exclusive of y . So the function only loops until y − 1 .Hence the first code return ( n − 1 ) ! while the second code return n ! .