From 8e85140d06203aeb9f5cdab8c44bd900c37ff5c3 Mon Sep 17 00:00:00 2001 From: daviddoji Date: Sun, 2 Oct 2022 18:38:34 +0200 Subject: [PATCH] Adopted new convention from template --- src/Python/Problems001-050/Problem050.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Python/Problems001-050/Problem050.py b/src/Python/Problems001-050/Problem050.py index e10e15e..687d7d8 100644 --- a/src/Python/Problems001-050/Problem050.py +++ b/src/Python/Problems001-050/Problem050.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Created on 18 Sep 2021 @@ -9,7 +9,7 @@ Solution for problem 50 of Project Euler https://projecteuler.net/problem=50 """ -from utils import timeit, list_primes, is_prime +from utils import is_prime, list_primes, timeit @timeit("Problem 50") @@ -19,12 +19,14 @@ def compute(): 41 = 2 + 3 + 5 + 7 + 11 + 13 - This is the longest sum of consecutive primes that adds to a prime below one-hundred. + This is the longest sum of consecutive primes that adds to a prime below + one-hundred. - The longest sum of consecutive primes below one-thousand that adds to a prime, - contains 21 terms, and is equal to 953. + The longest sum of consecutive primes below one-thousand that adds to a + prime, contains 21 terms, and is equal to 953. - Which prime, below one-million, can be written as the sum of the most consecutive primes? + Which prime, below one-million, can be written as the sum of the most + consecutive primes? """ ans = 0 @@ -40,12 +42,11 @@ def compute(): if is_prime(sum) and count > result: result = count ans = sum - # print(sum, result) if sum > 1_000_000: break + return ans if __name__ == "__main__": - - print(f"Result for Problem 50: {compute()}") \ No newline at end of file + print(f"Result for Problem 50 is {compute()}")