-
-
Save madebydna/538732 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
#!/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