Program to find Nth term of series 1, 3, 12, 60, 360…
Given a number N. The task is to write a program to find the Nth term in the below series:
1, 3, 12, 60, 360…
Examples:
Input: 2 Output: 3 Input: 4 Output: 60
Approach: The idea is to first find the factorial of the number (N+1), that is (N+1)!
Now, the N-th term in the above series will be:
N-th term = (N+1)!/2
Below is the implementation of the above approach:
C++
// CPP program to find N-th term of the series: // 1, 3, 12, 60, 360… #include <iostream> using namespace std; // Function to find factorial of N int factorial(int N) { int fact = 1; for (int i = 1; i <= N; i++) fact = fact * i; // return factorial of N+1 return fact; } // calculate Nth term of series int nthTerm(int N) { return (factorial(N + 1) / 2); } // Driver Function int main() { // Taking n as 6 int N = 6; // Printing the nth term cout << nthTerm(N); return 0; } |
chevron_right
filter_none
Java
// Java program to find N-th // term of the series: // 1, 3, 12, 60, 360 import java.util.*; import java.lang.*; import java.io.*; class GFG { // Function to find factorial of N static int factorial(int N) { int fact = 1; for (int i = 1; i <= N; i++) fact = fact * i; // return factorial of N return fact; } // calculate Nth term of series static int nthTerm(int N) { return (factorial(N + 1) / 2); } // Driver Code public static void main(String args[]) { // Taking n as 6 int N = 6; // Printing the nth term System.out.println(nthTerm(N)); } } |
chevron_right
filter_none
Python3
# Python 3 program to find # N-th term of the series: # 1, 3, 12, 60, 360… # Function for finding # factorial of N def factorial(N) : fact = 1 for i in range(1, N + 1) : fact = fact * i # return factorial of N return fact # Function for calculating # Nth term of series def nthTerm(N) : # return nth term return (factorial(N + 1) // 2) # Driver code if __name__ == "__main__" : N = 6 # Function Calling print(nthTerm(N)) |
chevron_right
filter_none
C#
// C# program to find N-th // term of the series: // 1, 3, 12, 60, 360 using System; class GFG { // Function to find factorial of N static int factorial(int N) { int fact = 1; for (int i = 1; i <= N; i++) fact = fact * i; // return factorial of N return fact; } // calculate Nth term of series static int nthTerm(int N) { return (factorial(N + 1) / 2); } // Driver Code static void Main() { int N = 6 ; // Printing the nth term Console.WriteLine(nthTerm(N)); } } // This code is contributed // by ANKITRAI1 |
chevron_right
filter_none
PHP
<?php // PHP program to find N-th term // of the series: 1, 3, 12, 60, 360… // Function to find factorial of N function factorial($N) { $fact = 1; for ($i = 1; $i <= $N; $i++) $fact = $fact * $i; // return factorial of N+1 return $fact; } // calculate Nth term of series function nthTerm($N) { return (factorial($N + 1) / 2); } // Driver Code // Taking n as 6 $N = 6; // Printing the nth term echo nthTerm($N); // This code is contributed // by chandan_jnu.. ?> |
chevron_right
filter_none
Output:
2520
Recommended Posts:
- Program to find Nth term of the series 3, 6, 18, 24, ...
- Program to find Nth term of the series 2, 4, 3, 4, 15...
- Program to find Nth term in the given Series
- Program to find the Nth term of the series 0, 3/1, 8/3, 15/5........
- Program to find the nth term of the series -2, 4, -6, 8....
- Program to find the Nth term of series 0, 4, 14, 30, 51, 80, 114, 154, 200, ...
- Program to find the Nth term of series 5, 10, 17, 26, 37, 50, 65, 82, ...
- Program to find the Nth term of the series 0, 5, 14, 27, 44, ........
- Program to find the Nth term of the series 0, 14, 40, 78, 124, ...
- Program to find the Nth term of the series 3, 7, 13, 21, 31.....
- Program to find the Nth term of series 5, 12, 21, 32, 45......
- Program to find N-th term of series 1, 2, 11, 12, 21….
- Program to find nth term of the series 1 4 15 24 45 60 92
- Program to find the Nth term of the series 3, 20, 63, 144, 230, ……
- Program to find Nth term of series 0, 11, 28, 51, 79, 115, 156, 203, ....
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.



