PatrickFrankAIU / ITWEB220-2404A

Learning resources for students in ITWEB 220, term 2404A.
0 stars 0 forks source link

Exercise: Loop with More Complex Calculation (but still no IF!) #17

Open PatrickFrankAIU opened 3 months ago

PatrickFrankAIU commented 3 months ago

Task: Calculate the sum of the products of consecutive numbers from 1 to 10.

Explanation: For each number n from 1 to 9, compute the product of n and n+1, then sum all these products.

Hint: Think about how you can combine numbers in a sequence to create a series of products. For each number from 1 to 9, consider how it relates to the next number in the sequence. This relationship might help you find a pattern to sum up all the products efficiently.

Note: The correct result in your output will be 330.

PatrickFrankAIU commented 3 months ago

This is a fun example of how a seemingly very complex mathematical construct can actually have a relatively simple programming solution. Here's what this problem looks like in a mathematical expression: image

If you want to learn more about coding mathematical calculations, including advanced ones, here are some suggestions: