Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:365235
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
def geom_sequence c
Enumerator.new { |y|
a = 1
loop {
y << a
a *= c
}
}
end
 
g = geom_sequence 2
p g.take_while{|i| i < 100}
#=>[1, 2, 4, 8, 16, 32, 64]
g = geom_sequence 0.5
p g.take(10)
#=>[1, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625, 0.0078125, 0.00390625, 0.001953125]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.