Given a number N, the task is to find the sum of first N Icosagonal Numbers.
The first few Icosagonal numbers are 1, 20, 57, 112, 185, 276…
Input: N = 3
1, 20 and 57 are the first three
Input: N = 5
- Initially, we need to create a function which will help us to calculate the N-th Icosagonal number.
- Now, Run a loop starting from 1 to N, to find the sum of all the Icosagonal number.
- Now, add all the above calculated Icosagonal numbers.
- Finally, display the sum of 1st N Icosagonal numbers.
Below is the implementation of the above approach:
Time complexity: O(N)
- How to swap two numbers without using a temporary variable?
- Program to find whether a no is power of two
- Lucky Numbers
- Program to find parity
- Ugly Numbers
- Write a program to add two numbers in base 14
- 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
- Count of Binary Digit numbers smaller than N
- Find Union and Intersection of two unsorted arrays
- Program for Fibonacci numbers
- Average of a stream of numbers
- Add two numbers without using arithmetic operators
- To find sum of two numbers without using any operator
- Count numbers that don't contain 3
- Find day of the week for a given date
- Given a number, find the next smallest palindrome
- Find the element that appears once
- Find the largest multiple of 2, 3 and 5
- Program to find amount of water in a given glass