Python code to demonstrate a method to compute the factorial digists sum, i.e. 100 factorial (100!).
This test exercise I’ve recieved when I was looking for a Trainee Python Developer position.
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))
648
Для кого ця стаття? Для таких як я сам, хто в часи пандемії та суттєвої…
Git is a free and open source distributed version control system designed to handle everything from small…
ASCII Tables ASCII abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication.…
Conda Managing Conda and Anaconda, Environments, Python, Configuration, Packages. Removing Packages or Environments Читати далі…
This website uses cookies.