From 80bb7a94ed2d138da5d3e7c682b0afaf423d70bb Mon Sep 17 00:00:00 2001 From: daviddoji Date: Fri, 30 Sep 2022 21:08:21 +0200 Subject: [PATCH] Adopted new convention from template --- src/Python/Problems001-050/Problem040.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Python/Problems001-050/Problem040.py b/src/Python/Problems001-050/Problem040.py index 47831e7..47294a2 100644 --- a/src/Python/Problems001-050/Problem040.py +++ b/src/Python/Problems001-050/Problem040.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Created on 23 Jun 2021 @@ -15,29 +15,30 @@ from utils import timeit @timeit("Problem 40") def compute(): """ - An irrational decimal fraction is created by concatenating the positive integers: + An irrational decimal fraction is created by concatenating the positive + integers: 0.123456789101112131415161718192021... It can be seen that the 12th digit of the fractional part is 1. - If d_n represents the n^th digit of the fractional part, find the value of the following expression. - - d_1 × d_{10} × d_{100} × d_{1_000} × d_{10_000} × d_{100_000} × d_{1_000_000} + If d_n represents the n^th digit of the fractional part, find the value of + the following expression. + d_1 x d_{10} x d_{100} x d_{1_000} x d_{10_000} x d_{100_000} + x d_{1_000_000} """ - fraction = '' + fraction = "" for i in range(1, 1_000_000): fraction += str(i) ans = 1 for i in range(7): - ans*= int(fraction[10**i - 1]) - + ans *= int(fraction[10**i - 1]) + return ans if __name__ == "__main__": - - print(f"Result for Problem 40: {compute()}") \ No newline at end of file + print(f"Result for Problem 40 is {compute()}")