Skip to content

Instantly share code, notes, and snippets.

@stuartellis
Created August 19, 2010 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stuartellis/538668 to your computer and use it in GitHub Desktop.
Save stuartellis/538668 to your computer and use it in GitHub Desktop.
#!/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
@madebydna
Copy link

!/usr/bin/env ruby -wKU

puts ps -o rss= -p #{$$}.to_i

def 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment