Ask Your Question
1

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

asked 2016-09-30 16:56:26 -0500

SDawkins gravatar image

updated 2016-10-01 04:13:55 -0500

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!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2016-10-01 04:13:43 -0500

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.

edit flag offensive delete link more

Comments

Super, thanks so much for your help.

SDawkins gravatar imageSDawkins ( 2016-10-01 15:36:00 -0500 )edit

^_^ .

tmonteil gravatar imagetmonteil ( 2016-10-01 15:38:06 -0500 )edit
4

answered 2016-10-01 15:36:06 -0500

SDawkins gravatar image

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

edit flag offensive delete link more

Comments

1

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

tmonteil gravatar imagetmonteil ( 2016-10-01 15:39:00 -0500 )edit

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: 2016-09-30 16:56:26 -0500

Seen: 65 times

Last updated: Oct 01 '16