public
Last active

A logarithmic generator: 1, 2, …, 8, 9, 10, 20, 30, …, 80, 90, 100, 200, …. Especially useful those times when you want to see how a function behaves over a wide range of numbers but don't want to have to actually look at all of those numbers.

  • Download Gist
Logarithmic generator
1 2 3 4 5 6 7
def log_gen(n):
import math
y = 1
while y < n:
adder = max(1, math.pow(10, int(math.log10(y))))
yield int(y)
y = y + adder

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.