Last active
August 29, 2015 14:21
-
-
Save napsternxg/6d9d67846cac96675f61 to your computer and use it in GitHub Desktop.
Generate 10 power range like 1,2,3,..10,20,30,...90,100,200,300...
This file contains 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
max_n = 1200 | |
[k for k in range(1,max_n) if k % 10**int(np.log10(k)) == 0] | |
""" | |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000] | |
""" | |
#More computationally effective solution for large max_n | |
max_n = 1e20 | |
a = [] | |
k = 1 | |
while k < max_n: | |
a.append(k) | |
k = k + 10**int(np.log10(k)) # increment k by the lower 10 step nearest to the number | |
a.append(max_n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment