I have decided to use this blog to display the source code for Project Euler answers (and eventually other programming challenges as well). Enjoy!
#Project Euler
#Problem 1
x , total = 0,0
while x < 1000
total += x if x % 3 == 0 || x % 5 == 0
x+=1
end
range = 0..999
a = range.inject(0) do |sum,element|
element%3==0 || element%5==0 ? sum+element : sum
end
puts total
puts a
This comment has been removed by a blog administrator.
ReplyDeletevery interesting indeed!
ReplyDeleteProject Euler?
ReplyDeleteFun times :D
ReplyDeletegood info
ReplyDelete@TSFan: Yeah, it's a fun fusion of Mathematical challenges and Ruby coding. Check it out at www.projecteuler.com
ReplyDeleteThank's !
ReplyDelete