Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Jupyter notebook Project Euler Problem 16.ipynb

34 views
Kernel: Anaconda (Python 3)
def findsum(): n=input('give me a number to put 2 to the power to') n=int(n) a=1 z=1 for i in range(n): a=a*2 for j in range(n): z=z*2 print ('the value that we are going to sum the terms of is ',a) var=1 f=1 while z//10>0: f=f+1 z=z/10 print('the number has ',f,'terms') c=0 for k in range(f): b=a%10 c=c+b a=a//10 print('the sum of all terms is ',c)
findsum()
give me a number to put 2 to the power to1000 the value that we are going to sum the terms of is 10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376 the number has 302 terms the sum of all terms is 1366