Created
November 25, 2013 16:08
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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