Doing Python or R right means using vector/matrix operations in e.g. numpy. Those will be faster.
Just think twice before using a for loop. Most of the time it is not needed.
Just think twice before using a for loop. Most of the time it is not needed.
The nested loop becomes: j <- sum((seq_len(100000) - 1) %% u) a <- a + j + r