193k views
0 votes
Write a program to output The sum of the cubes of odd integers between 11 and 49​

2 Answers

6 votes

Answer:

779400

Step-by-step explanation:

There are 20 odd integers between 11 and 49, they are 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49. There are 5 odd numbers before 11, and 25 odd numbers from 1 to 49.

Use the formula to calculate the sum

25^2 * (2 * 25^2 - 1) - 5^2 * (2 * 5^2 - 1)

= 25^2 * (2 * 625 - 1) - 5^2 * (2 * 25 - 1)

= 25^2 * (1250 - 1) - 5^2 * (50 - 1)

= 625 * 1249 - 25 * 49

= 780625 - 1225

= 779400

Verify:

11^3 + 13^3 + 15^3 + 17^3 + 19^3 + 21^3 + 23^3 + 25^3 + 27^3 + 29^3 + 31^3 + 33^3 + 35^3 + 37^3 + 39^3 + 41^3 + 43^3 + 45^3 + 47^3 + 49^3

= 1331 + 2197 + 3375 + 4913 + 6859 + 9261 + 12167 + 15625 + 19683 + 24389 + 29791 + 35937 + 42875 + 50653 + 59319 + 68921 + 79507 + 91125 + 103823 + 117649

= 779400

User NIKHIL RANE
by
8.3k points
3 votes

Here's a Python program that will output the sum of the cubes of odd integers between 11 and 49:

sum_of_cubes = 0

for i in range(11, 50):

if i % 2 == 1:

sum_of_cubes += i ** 3

print("The sum of the cubes of odd integers between 11 and 49 is:", sum_of_cubes)

This program initializes a variable called sum_of_cubes to 0, then uses a for loop to iterate through the range of numbers between 11 and 49. For each number in that range, it checks if the number is odd by using the modulus operator (%) to check if the number is divisible by 2 with a remainder of 1. If the number is odd, it adds the cube of that number to the sum_of_cubes variable.

Finally, the program prints out the total sum of the cubes of the odd integers between 11 and 49.

User JensJensen
by
6.9k points