I\'m having trouble understanding how to make this into a formula.
for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j += i) {
Well, you can methodically use Sigma notation: