Given a level L. The task is to find the sum of all the integers present at the given level in Pascal’s triangle .
A Pascal triangle with 6 levels is as shown below:
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
Input: L = 3
1 + 2 + 1 = 4
Input: L = 2
Approach: If we observe carefully the series of the sum of levels will go on like 1, 2, 4, 8, 16…., which is a GP series with a = 1 and r = 2.
Therefore, sum of Lth level is L’th term in the above series.
Lth term = 2L-1
Below is the implementation of the above approach:
Time Complexity: O(1)
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Sum of all the numbers present at given level in Modified Pascal’s triangle
- Sum of numbers in the Kth level of a Fibonacci triangle
- Maximum of all the integers in the given level of Pascal triangle
- Sum of all palindrome numbers present in an Array
- Sum of all mersenne numbers present in an array
- Sum of all perfect numbers present in an array
- Program to find if two numbers and their AM and HM are present in an array using STL
- Sum of all Palindrome Numbers present in a Linked list
- Sum of all perfect numbers present in an Linked list
- Sum of all the numbers in the Nth row of the given triangle
- Triangle of numbers arising from Gilbreath's conjecture
- Biggest Reuleaux Triangle within a Square which is inscribed within a Right angle Triangle
- Program to print a Hollow Triangle inside a Triangle
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle
- Probability of a key K present in array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.