From 95764932a38bb7741fd0ffd9a18b6e2eb10fe6ad Mon Sep 17 00:00:00 2001 From: ABK1121 <113099639+ABK1121@users.noreply.github.com> Date: Sun, 18 Sep 2022 13:28:44 +0500 Subject: [PATCH] Update solution.py --- Q1/solution.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Q1/solution.py b/Q1/solution.py index 4429a19..df145d3 100644 --- a/Q1/solution.py +++ b/Q1/solution.py @@ -1 +1,15 @@ -## Add code below with answer clearly stated +n = 100 +fact = 1 + +for i in range(1, n+1): + fact = fact * i + +# Convert number to string +text_fact = str(fact) + +# Initialize empty list for every letter of factorial string +summ = [] + +for letter in text_fact: + summ.append(int(letter)) +print(sum(summ))