Open In App

Icositrigonal Number

Last Updated : 17 Mar, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Given a number N, the task is to find Nth Icositrigonal number or not. 
 

An Icositrigonal number is class of figurate number. It has 23 – sided polygon called Icositrigon. The N-th Icositrigonal number count’s the 23 number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few Icositrigonol numbers are 1, 23, 66, 130, 215, 321, 448 … 
 


Examples: 
 

Input: N = 2 
Output: 23 
Explanation: 
The second Icositrigonol number is 66. 
Input: N = 6 
Output: 321 
 


 


Approach: The N-th Icositrigonal number is given by the formula: 
 

Tn = (21n^2 - 19n)/2


Below is the implementation of the above approach:
 

C++

// C++ program to find nth
// Icositrigonal number
 
#include <bits/stdc++.h>
using namespace std;
 
// Function to find N-th
// Icositrigonal number
int Icositrigonal_num(int n)
{
    // Formula to calculate nth
    // Icositrigonal number
    return (21 * n * n - 19 * n) / 2;
}
 
// Driver Code
int main()
{
    int n = 3;
    cout << Icositrigonal_num(n) << endl;
     
    n = 10;
    cout << Icositrigonal_num(n);
 
    return 0;
}

                    

Java

// Java program to find nth
// Icositrigonal number
class GFG{
 
// Function to find N-th
// Icositrigonal number   
static int IcositrigonalNum(int n)
{
     
    // Formula to calculate nth
    // Icositrigonal number
    return (21 * n * n - 19 * n) / 2;
}
 
// Driver code
public static void main(String[] args)
{
    int n = 3;
    System.out.print(IcositrigonalNum(n) + "\n");
     
    n = 10;
    System.out.print(IcositrigonalNum(n));
}
}
 
// This code is contributed by spp____

                    

Python3

# Python3 program to find nth
# Icositrigonal number
 
# Function to find N-th
# Icositrigonal number
def IcositrigonalNum(n):
     
    # Formula to calculate nth
    # Icositrigonal number
    return (21 * n * n - 19 * n) / 2;
 
# Driver code
n = 3
print(IcositrigonalNum(n))
 
n = 10
print(IcositrigonalNum(n))
 
# This code is contributed by spp____

                    

C#

// C# program to find nth
// Icositrigonal number
using System;
 
class GFG{
 
// Function to find N-th
// Icositrigonal number    
static int IcositrigonalNum(int n)
{
     
    // Formula to calculate nth
    // Icositrigonal number
    return (21 * n * n - 19 * n) / 2;
}
 
// Driver code
public static void Main()
{
    int n = 3;
    Console.WriteLine(IcositrigonalNum(n));
     
    n = 10;
    Console.WriteLine(IcositrigonalNum(n));
}
}
 
// This code is contributed by spp____

                    

Javascript

<script>
 
    // Javascript program to find nth 
    // Icositrigonal number
     
    // Function to find N-th 
    // Icositrigonal number 
    function Icositrigonal_num(n) 
    
        // Formula to calculate nth 
        // Icositrigonal number 
        return (21 * n * n - 19 * n) / 2; 
    
     
    let n = 3; 
    document.write(Icositrigonal_num(n) + "</br>"); 
       
    n = 10; 
    document.write(Icositrigonal_num(n));
     
</script>

                    

Output: 
66
955

 

Reference: https://en.wikipedia.org/wiki/Polygonal_number


 



Similar Reads

Program to check if N is a Icositrigonal number
Given an integer N, the task is to check if it is an Icositrigonal number or not. Icositrigonal number is a class of figurate number. It has 23 – sided polygon called Icositrigon. The N-th Icositrigonal number count’s the 23 number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few Icositrigon
4 min read
Check Whether a Number is an Anti Prime Number(Highly Composite Number)
Given a positive integer N, the task is to tell whether it's an anti-prime number or not. Anti-Prime Numbers (Highly Composite Number): A positive integer that has more divisors than any positive number smaller than it, is called an Anti-Prime Number (also known as Highly Composite Number). Following is the list of the first 10 anti-prime numbers a
5 min read
Number of factors of very large number N modulo M where M is any prime number
Given a large number N, the task is to find the total number of factors of the number N modulo M where M is any prime number. Examples: Input: N = 9699690, M = 17 Output: 1 Explanation: Total Number of factors of 9699690 is 256 and (256 % 17) = 1Input: N = 193748576239475639, M = 9 Output: 8 Explanation: Total Number of factors of 9699690 is 256 an
8 min read
Permutation of a number whose sum with the original number is equal to another given number
Given two integers A and C, the task is to check if there exists a permutation of the number A such that the sum of the number A and its permutation is equal to C. Examples: Input: A = 133, C = 446Output: YesExplanation: One of the permutation of A is 313. Therefore, sum = 133 + 313 = 446, which is equal to C. Input: A = 200, C = 201Output: No Naiv
6 min read
Minimum number of moves to make M and N equal by repeatedly adding any divisor of number to itself except 1 and the number
Given two numbers N and M, the task is to find the minimum number of moves to change N to M or -1 if it's impossible. In one move, add to the current number any of its divisors not equal to 1 and the number itself. Examples: Input: N = 4, M = 24Output: 5Explanation: the number 24 can be reached starting from 4 using 5 operations: 4-&gt;6-&gt;8-&gt;
16 min read
Given a number as a string, find the number of contiguous subsequences which recursively add up to 9
Given a number as a string, write a function to find the number of substrings (or contiguous subsequences) of the given string which recursively add up to 9. Example: Digits of 729 recursively add to 9, 7 + 2 + 9 = 18 Recur for 18 1 + 8 = 9 Examples: Input: 4189 Output: 3 There are three substrings which recursively add to 9. The substrings are 18,
6 min read
Number of times the largest perfect square number can be subtracted from N
Given a number N. At every step, subtract the largest perfect square( ? N) from N. Repeat this step while N &gt; 0. The task is to count the number of steps that can be performed. Examples: Input: N = 85 Output: 2 First step, 85 - (9 * 9) = 4 Second step 4 - (2 * 2) = 0 Input: N = 114 Output: 4 First step, 114 - (10 * 10) = 14 Second step 14 - (3 *
7 min read
Program to calculate the number of odd days in given number of years
Given an integer N, the task is to find the number of odd days in the years from 1 to N. Odd Days: Number of odd days refer to those days that are left in a certain year(s) when it's days gets converted into weeks. Say, an ordinary year has 365 days, that is 52 weeks and one odd day. This means, out of the 365 days in an ordinary year, 364 days wil
7 min read
Check if given number is Emirp Number or not
An Emirp Number (prime spelled backwards) is a prime number that results in a different prime when its decimal digits are reversed. This definition excludes the related palindromic primes. Examples : Input : n = 13Output : 13 is Emirp!Explanation :13 and 31 are both prime numbers. Thus, 13 is an Emirp number.Input : n = 27Output : 27 is not Emirp.O
10 min read
Given a number N in decimal base, find number of its digits in any base (base b)
Given A Number n in a base 10, find the number of digits in its base b representation. Constraints : [Tex]N \in \mathbb{W} [/Tex]Whole Examples : Input : Number = 48 Base = 4 Output: 3 Explanation : (48)10 = (300)4 Input : Number = 1446 Base = 7 Output: 4 Explanation : (446)10 = (4134)7 A simple approach: convert the decimal number into the given b
8 min read
Article Tags :
Practice Tags :