1 | initial version |

There is a difference between Sage and Python (2.x) concerning the division operator **/** .
In Python 2.x the operator **/** returns the floor of the result of division if the operands are integers (Python ints).
In Sage the operator **/** returns the result as rational number (if so) if the operands are **Sage** integers.
The Python function `range`

returns a list of Python integers. In your nested for loops all operands are Python ints, so you get the floor of the division result.
In your second code example **N** (and therefor **n**) is an Sage integer, so you get the rational numbers as result.

The Sage function `srange`

returns a list of Sage integers. With `srange(N,N+1)`

in your first code **n** becomes a Sage integer.

You can see the difference by placing some `print type(k)`

and `print type(n)`

commands inside the loops.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.