Skip to content

Instantly share code, notes, and snippets.

@thekindlyone
Created January 10, 2014 22:44
Show Gist options
  • Save thekindlyone/8364163 to your computer and use it in GitHub Desktop.
Save thekindlyone/8364163 to your computer and use it in GitHub Desktop.
for vivek
i=0
sum=0
giveup3=0
giveup5=0
lim=1000
while True:
num3=3*i #generating multiples for processing
num5=5*i # ^
if num3>=lim: # if multiple of 3>limit then stop adding those, and set flag
giveup3=1
num3=0
if num5>=lim: # same as ^ but for 5
giveup5=1
num5=0
if giveup3 and giveup5: # if both give up no more chance of finding any more hence stop
break
if num3%5==0: # to handle multiples of 15
num3=0
sum=sum+num3+num5
print i,'. sum = ',sum,' num3 = ',num3,' num5 = ',num5,' giveup3 = ',giveup3,' giveup5 = ',giveup5 #log
i+=1 #counter
print sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment