Ask Your Question
1

How can I find the sum of a series of integers with powers eg, n^(n 1)?

asked 8 years ago

SDawkins gravatar image

updated 8 years ago

tmonteil gravatar image

I'm trying to find the sage code that will calculate the sum of 1^2 + 3^4 + 5^6....+107^108 and I'm totally stumped. Any help would be greatly appreciated. Thank you!

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
3

answered 8 years ago

tmonteil gravatar image

This looks like homework. Here are some hints:

  • to create the list of the terms, search for list comprehension,
  • to get only odd numbers, note that the range function has a step option, so that you can jump 2 by 2,
  • then use the sum function to sum all elements of the list you obtained.

The result should start with 149 and end with 478.

Preview: (hide)
link

Comments

Super, thanks so much for your help.

SDawkins gravatar imageSDawkins ( 8 years ago )

^_^ .

tmonteil gravatar imagetmonteil ( 8 years ago )
4

answered 8 years ago

SDawkins gravatar image

sum([ i^(i+1) for i in [1, 3, 5..107] ])

Preview: (hide)
link

Comments

1

Amazing, i did not know that such ellipsis was able to guess the step !

tmonteil gravatar imagetmonteil ( 8 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 8 years ago

Seen: 1,074 times

Last updated: Oct 01 '16