Project Euler

katastrophe

Junior Member
May 30, 2006
14
0
0
For all of you programmers, check out Project Euler and see if you can figure out some of the math problems on there. It gets quite addicting, actually. I've been using Python, which I'm new at, and have managed to solve 5 so far today.
 

NanoStuff

Banned
Mar 23, 2006
2,981
1
0
"Find the sum of digits in 100!"

(0..100).inject {|x,y| x+y}

Hehehe, pwned! I *heart* Ruby :)

Interesting site, I visit http://rubyquiz.com/, which isn't entirely math oriented. Ruby specific, but if you don't care for the answer, the challenges can effectively be taken up in other languages.
 

exdeath

Lifer
Jan 29, 2004
13,679
10
81
Originally posted by: NanoStuff
"Find the sum of digits in 100!"

(0..100).inject {|x,y| x+y}

Hehehe, pwned! I *heart* Ruby :)

Interesting site, I visit http://rubyquiz.com/, which isn't entirely math oriented. Ruby specific, but if you don't care for the answer, the challenges can effectively be taken up in other languages.

#define SUM100 5050

much faster :)

Or if you need real time with any number n and not just 100:

((n+1)*n)>>1;

Edit: didnt see the factorial.