Created
August 19, 2010 19:24
-
-
Save stuartellis/538668 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU | |
puts `ps -o rss= -p #{$$}`.to_i | |
current_fib = 1 | |
fib_numbers = [] | |
for i in 1..4000000 do | |
if i == current_fib * 2 | |
fib_numbers << i | |
current_fib = i | |
end | |
end | |
=begin | |
fib_numbers.each do |n| | |
puts n | |
end | |
=end | |
puts `ps -o rss= -p #{$$}`.to_i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!/usr/bin/env ruby -wKU
puts
ps -o rss= -p #{$$}
.to_idef fibonacci
a, b = 0, 1
sum = 0
while a < 4000000
printf("%d\n", a)
sum += a if a.even?
a,b = b,a+b
end
puts "-------------"
puts sum
end
fibonacci
puts
ps -o rss= -p #{$$}
.to_i