Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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.