Given a number N, the task is to find the sum of the first N Icosidigonal Numbers.
The first few Icosidigonal numbers are 1, 22, 63, 124, 205, 306 …
Input: N = 3
1, 22 and 63 are the first three Icosidigonal numbers.
Input: N = 6
- Initially, we need to create a function which will help us to calculate the Nth icosidigonal number.
- Now, run a loop starting from 1 to N, to find ith icosidigonal numbers.
- Add all the above calculated icosidigonal numbers.
- Finally, display the sum of the first N Icosidigonal numbers.
Below is the implementation of the above approach:
Time complexity: O(N).
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Write a program to reverse digits of a number
- Program to find whether a no is power of two
- Write an Efficient Method to Check if a Number is Multiple of 3
- Program to find parity
- Write an Efficient C Program to Reverse Bits of a Number
- Minimum number of jumps to reach end
- Find minimum number to be divided to make a number a perfect square
- Find whether a given number is a power of 4 or not
- Print all combinations of points that can compose a given number
- Find Union and Intersection of two unsorted arrays
- Check if a number is multiple of 5 without using / and % operators
- To find sum of two numbers without using any operator
- Find day of the week for a given date
- Given a number, find the next smallest palindrome
- Find the element that appears once
- Count the number of possible triangles
- Select a random number from stream, with O(1) space
- Find the largest multiple of 2, 3 and 5
- Program to find amount of water in a given glass
- Program to convert a given number to words