"Steven D'Aprano" <st...@pearwood.info> wrote

(We can of course do some fancy math to speed this particular
sum up since the result for any power of ten has a common pattern,
but I wouldn't expect the compiler optimiser to be that clever)

No fancy maths needed,

The sum of 1,2,3,4,...,N is given by a simple formula: 1/2*N*(N+1).

Depends how you define fancy... I count that as pretty fancy maths for a compiler optimiser to recognise! :-)

anecdote about the great mathematician Carl Gauss

I like it! I hadn't come across that one before.

Alan G.

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to