Last Updated: 27 May, 2025

Table Summation

Easy

Problem statement

You are given an integer 'N'.


Return the summation of its multiplication table up to 10.


For Example :
Let 'N' = 5.
The multiplication table of 5 up to 10 is: 5, 10, 15, 20, 25, 30, 35, 40, 45, 50.
The summation is 5 + 10 + 15 + 20 + 25 + 30 + 35 + 40 + 45 + 50 = 275.
Therefore, the answer is 275.
Input Format :
The first line contains a single integer 'N'.
Output Format :
Return the summation of the multiplication table of 'N' up to 10.
Note :
You don’t need to print anything. Just implement the given function.
Constraints :
1 <= 'N' <= 1000

Time Limit: 1 sec

Approaches

01 Approach

Approach:

  • Factor out 'N' from the summation of its multiples.
    • The summation of the multiplication table of 'N' up to 10 can be written as: S=(N×1)+(N×2)+(N×3)+(N×4)+(N×5)+(N×6)+(N×7)+(N×8)+(N×9)+(N×10)
    • Using the distributive property, we can factor out 'N': S=N×(1+2+3+4+5+6+7+8+9+10)
  • The remaining series is the sum of the first 10 natural numbers, which has a direct mathematical formula.
    • The sum of the first 'k' natural numbers is given by the formula: 2k(k+1)​
    • In this case, k=10, so the sum of the first 10 natural numbers is: 210(10+1)​=210×11​=55
  • Therefore, the summation of the multiplication table of 'N' up to 10 is: S=N×55

Algorithm:

  • Return N * 55.