Skip to content

Instantly share code, notes, and snippets.

@napsternxg
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save napsternxg/6d9d67846cac96675f61 to your computer and use it in GitHub Desktop.
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...
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