Skip to content

Instantly share code, notes, and snippets.

@cymruu
Created June 12, 2017 17:07
Show Gist options
  • Save cymruu/9f9dbf76846f4249ab2635c832667fe8 to your computer and use it in GitHub Desktop.
Save cymruu/9f9dbf76846f4249ab2635c832667fe8 to your computer and use it in GitHub Desktop.
number = 15
def getOnesInNumber(n):
numberOfOnes = 0
while(n):
found = n%10
n//=10
if found==1: numberOfOnes+= found
return numberOfOnes
found = 0
for i in range(15):
found+=getOnesInNumber(i)
print(found)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment