Created
December 13, 2012 16:01
-
-
Save JordanReiter/4277424 to your computer and use it in GitHub Desktop.
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.
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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment