Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- maxvalue = 10**4
- benfordList = [[0], [0], [0], [0], [0], [0], [0], [0], [0]]
- for i in range(1, maxvalue+1):
- for first in range(1, 10):
- if str((i)**2).startswith(str(first)):
- benfordList[first-1][0] += 1
- for i in range(len(benfordList)):
- print("Numbers starting with ", i+1, ": ", benfordList[i][0], sep='')
- print("Percentage of total: ", benfordList[i][0] / maxvalue * 100, " %", sep='')
Advertisement
Add Comment
Please, Sign In to add comment