Eularproject 48: Summing with arrays

Source: Internet
Author: User
Tags pow

Problem 48
The series, 1 1 + 2 2 + 3 3 +...+ ten ten =10405071317 .

Find the last ten digits of the series, 1 1 + 2 2 + 3 3 +...+ the .

Answer:
9110846700
Completed on Thu, Jul 2015, 17:26

Initial thinking, you can use the method of meta-pair to calculate the number of times each number needs to multiply

def func (a): forIinchRange0,Len(a)):aI [1]*=aI [0]return aa=[[i,i] forIinchRange +,0,-1)]result=0 while Len(a) >0:result+=a. Pop () [1]a=func (a) Print (result% (POW (Ten,Ten)))

Further, you can use the array subscript to get the number of multiply

def func (a): forIinchRange0,Len(a)):a[i]=a[I]* ( +-I.)return aa=[i forIinchRange +,0,-1)]result=0 while Len(a) >0:result+=a. Pop ()a=func (a) Print (result% (POW (Ten,Ten)))

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Eularproject 48: Summing with arrays

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.