I've decided that if i'm going to solve 332 problem's it's best be in a separate blog, so i'm opening a new blog, i think i'll call it: 'ProjectEuler solver'
Here it goes... http://projecteulersolver.blogspot.com/
Showing posts with label Project Euler. Show all posts
Showing posts with label Project Euler. Show all posts
Sunday, April 10, 2011
Project Euler - Problem 2 - Tcl
#Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: #1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... #By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. proc problem2 {} { set term 2 set term-1 1 set sum 0 while {$term <= 4000000} { if {($term % 2) == 0} { incr sum $term } set tmp ${term-1} set term-1 $term set term [expr $term + $tmp] } return $sum } # solution-2: 4613732
Labels:
CS,
General,
math,
Problems,
Programming,
Project Euler,
TCL
Project Euler - Problem 1 - Tcl
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. proc Problem1 {} { set items {} for {set idx 3} {$idx<1000} {incr idx 3} { lappend items $idx } for {set idx 5} {$idx<1000} {incr idx 5} { if { [lsearch $items $idx] < 0 } { lappend items $idx } } set rval 0 foreach item $items { set rval [expr $rval + $item] }
return $rval } # solution: 233168
Labels:
CS,
General,
math,
Problems,
Programming,
Project Euler,
TCL
Saturday, April 9, 2011
Project Euler - Very nice problems for every programmer.
Just found this very nice site - http://projecteuler.net/ while searching for some nice math/SW problems to sharpen my knowledge.
I intend to practice through them, very nice job guys!! Very nice idea!!
One problem for a week, ~54 weeks a year, lots of problems to solve :).
Anyway it looks fun, there are around 332 problems as I write.
When I'll solve a problem, I'll post it here...
I intend to practice through them, very nice job guys!! Very nice idea!!
One problem for a week, ~54 weeks a year, lots of problems to solve :).
Anyway it looks fun, there are around 332 problems as I write.
When I'll solve a problem, I'll post it here...
Labels:
CS,
General,
math,
Problems,
Programming,
Project Euler
Subscribe to:
Posts (Atom)