Open In App

Heptacontagon Number

Last Updated : 23 Jun, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Given a number N, the task is to find Nth Heptacontagon number
 

A Heptacontagon number is class of figurate number. It has 70 – sided polygon called heptacontagon. The N-th heptacontagon number count’s the 70 number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few heptacontagonol numbers are 1, 70, 207, 412 … 
 


Examples: 
 

Input: N = 2 
Output: 70 
Explanation: 
The second heptacontagonol number is 70. 
Input: N = 3 
Output: 207 
 


 


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

  • Nth term of s sided polygon = \frac{((s-2)n^2 - (s-4)n)}{2}
     
  • Therefore Nth term of 70 sided polygon is
     

Tn =\frac{((70-2)n^2 - (70-4)n)}{2} =\frac{(68n^2 - 66)}{2}


  •  


Below is the implementation of the above approach: 
 

C++

// C++ program for above approach
#include <bits/stdc++.h>
using namespace std;
 
// Finding the nth heptacontagon number
int heptacontagonNum(int n)
{
    return (68 * n * n - 66 * n) / 2;
}
 
// Driver code
int main()
{
    int N = 3;
     
    cout << "3rd heptacontagon Number is = "
         << heptacontagonNum(N);
 
    return 0;
}
 
// This code is contributed by shivanisinghss2110

                    

C

// C program for above approach
#include <stdio.h>
#include <stdlib.h>
 
// Finding the nth heptacontagon Number
int heptacontagonNum(int n)
{
    return (68 * n * n - 66 * n) / 2;
}
 
// Driver code
int main()
{
    int N = 3;
    printf("3rd heptacontagon Number is = %d",
           heptacontagonNum(N));
 
    return 0;
}

                    

Java

// Java program for the above approach
class GFG{
 
// Finding the nth heptacontagon number
static int heptacontagonNum(int n)
{
    return (68 * n * n - 66 * n) / 2;
}
 
// Driver Code
public static void main(String[] args)
{
    int N = 3;
    System.out.println("3rd heptacontagon Number is = " +
                                    heptacontagonNum(N));
}
}
 
// This code is contributed by rutvik_56

                    

Python3

# Python3 program for above approach
 
# Finding the nth heptacontagon Number
def heptacontagonNum(n):
 
    return (68 * n * n - 66 * n) // 2;
 
# Driver code
N = 3;
print("3rd heptacontagon Number is =",
                 heptacontagonNum(N));
 
# This code is contributed by Akanksha_Rai

                    

C#

// C# program for the above approach
using System;
class GFG{
 
// Finding the nth heptacontagon number
static int heptacontagonNum(int n)
{
    return (68 * n * n - 66 * n) / 2;
}
 
// Driver Code
public static void Main()
{
    int N = 3;
    Console.Write("3rd heptacontagon Number is = " +
                               heptacontagonNum(N));
}
}
 
// This code is contributed by Akanksha_Rai

                    

Javascript

<script>
 
// JavaScript program for above approach
 
// Finding the nth heptacontagon number
function heptacontagonNum(n)
{
    return (68 * n * n - 66 * n) / 2;
}
 
// Driver code
 
var N = 3;   
document.write("3rd heptacontagon Number is = " + heptacontagonNum(N));
 
 
</script>

                    

Output: 
3rd heptacontagon Number is = 207

 

Time Complexity: O(1)

Auxiliary Space: O(1)

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


 



Previous Article
Next Article

Similar Reads

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
Minimum number using set bits of a given number
Given an unsigned number, find the minimum number that could be formed by using the bits of the given unsigned number. Examples : Input : 6 Output : 3 Binary representation of 6 is 0000....0110. Smallest number with same number of set bits 0000....0011. Input : 11 Output : 7 Simple Approach: 1. Find binary representation of the number using simple
4 min read
Article Tags :
Practice Tags :