A number is termed as a tetrahedral number if it can be represented as a pyramid with a triangular base and three sides, called a tetrahedron. The nth tetrahedral number is the sum of the first n triangular numbers.
The first ten tetrahedral numbers are:
1, 4, 10, 20, 35, 56, 84, 120, 165, 220, …
Formula for nth tetrahedral number:
Tn = (n * (n + 1) * (n + 2)) / 6
The proof uses the fact that the nth tetrahedral number is given by, Trin = (n * (n + 1)) / 2 It proceeds by induction. Base Case T1 = 1 = 1 * 2 * 3 / 6 Inductive Step Tn+1 = Tn + Trin+1 Tn+1 = [((n * (n + 1) * (n + 2)) / 6] + [((n + 1) * (n + 2)) / 2] Tn+1 = (n * (n + 1) * (n + 2)) / 6
Below is the implementation of above idea :
Time Complexity: O(1).
- Program to print tetrahedral numbers upto Nth term
- Centered tetrahedral number
- Print N lines of 4 numbers such that every pair among 4 numbers has a GCD K
- Numbers less than N which are product of exactly two distinct prime numbers
- Count numbers which can be constructed using two numbers
- Count numbers which are divisible by all the numbers from 2 to 10
- Maximum sum of distinct numbers such that LCM of these numbers is N
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
- Absolute Difference between the Sum of Non-Prime numbers and Prime numbers of an Array
- Print numbers such that no two consecutive numbers are co-prime and every three consecutive numbers are co-prime
- Add two numbers using ++ and/or --
- Sum of first n even numbers
- Sum of all even numbers in range L and R
- Sum of cubes of first n even numbers
- Sum of even numbers at even position
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.