Skip to content

Instantly share code, notes, and snippets.

@ixxra
Created November 25, 2013 16:08
Show Gist options
  • Save ixxra/7643793 to your computer and use it in GitHub Desktop.
Save ixxra/7643793 to your computer and use it in GitHub Desktop.
Si enlistamos todos los numeros naturales menores que 10 y que son multiplos de 3 o 5, estos son 3, 5, 6 y 9. La suma de estos numeros es 23. Encuentra la suma de todos los multiplos de 3 o 5 que son menores que 1000.
#Initialization
sum = 0
mult = 3
#Sumamos multiplos de 3 que no sean multiplos de 5
while mult < 1000:
if mult % 5 != 0:
if mult %3 != 0:
sum = sum + mult
mult = mult + 3
#Ahora sumamos todos los multiplos de 5
mult = 5
while mult < 1000:
sum = sum + mult
mult = mult + 5
print sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment