From d60316bd48e038393069329a8684f70164917386 Mon Sep 17 00:00:00 2001 From: cclauss Date: Thu, 6 Jun 2019 19:24:59 +0200 Subject: [PATCH 1/3] Fix the Python Syntax Error that is causing LGTM to fail The __elif__ in this solution will __never__ be executed. --- Project Euler/Problem 01/sol5.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Project Euler/Problem 01/sol5.py b/Project Euler/Problem 01/sol5.py index 2cb67d2524e2..f392b9d57574 100644 --- a/Project Euler/Problem 01/sol5.py +++ b/Project Euler/Problem 01/sol5.py @@ -1,8 +1,9 @@ -a=3 -result=0 -while a=<1000: - if(a%3==0 and a%5==0): - result+=a - elif(a%15==0): - result-=a +a = 3 +result = 0 +while a <= 1000: + if a % 3 == 0 and a % 5 == 0: + result += a + elif a % 15 == 0: + result -= a + print(result) From 2f43ab46b48584d00859c3fdbb2a5953462f8300 Mon Sep 17 00:00:00 2001 From: cclauss Date: Sat, 8 Jun 2019 08:54:10 +0200 Subject: [PATCH 2/3] Correct the solution --- Project Euler/Problem 01/sol5.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Project Euler/Problem 01/sol5.py b/Project Euler/Problem 01/sol5.py index f392b9d57574..7014f546f8c1 100644 --- a/Project Euler/Problem 01/sol5.py +++ b/Project Euler/Problem 01/sol5.py @@ -1,9 +1,3 @@ -a = 3 -result = 0 -while a <= 1000: - if a % 3 == 0 and a % 5 == 0: - result += a - elif a % 15 == 0: - result -= a +"""Find the sum of all the multiples of 3 or 5 below 1000.""" -print(result) +print(sum(i if 0 in (i % 3, i % 5) else 0 for i in range(1000))) From a83f18fb2c7b1d2f5181b144c6df1a0df58ff792 Mon Sep 17 00:00:00 2001 From: cclauss Date: Sat, 8 Jun 2019 09:29:03 +0200 Subject: [PATCH 3/3] https://projecteuler.net/problem=1 --- Project Euler/Problem 01/sol5.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Project Euler/Problem 01/sol5.py b/Project Euler/Problem 01/sol5.py index 7014f546f8c1..3a6d3089db15 100644 --- a/Project Euler/Problem 01/sol5.py +++ b/Project Euler/Problem 01/sol5.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 + """Find the sum of all the multiples of 3 or 5 below 1000.""" +# https://projecteuler.net/problem=1 + print(sum(i if 0 in (i % 3, i % 5) else 0 for i in range(1000)))