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