← Back to challenges

Recursion: Sum of Multiplication

PythonHardmathnumbersrecursion

Instructions

Given a number, return the total sum of that number multiplied by every number between 1 and 10. Do not use the sum() built-in function.

Examples

multi_sum(1) ➞ 55
# 1 x 1 + 1 x 2 + 1 x 3 ...... 1 x 9 + 1 x 10 = 55

multi_sum(6) ➞ 330
# 6 x 1 + 6 x 2 + 6 x 3 ...... 6 x 9 + 6 x 10 = 330

multi_sum(10) ➞ 550

multi_sum(8) ➞ 440

multi_sum(2) ➞ 110

Notes

Use recursion to solve this challenge.

python3
Loading editor…
⌘ ↡ to run
Walks through the solution with reasoning and edge cases.
Next: Opposite House 🏘️ β†’