Program to find Nth term of the series 3 , 6 , 18 , 24 , ... | Class to calculate Nth term of series ; By using above formula ; Main class for main method ; get the value of N ; create object of Class Nth ; Calculate and print the Nth term
import java . io . * ; class Nth { public int nthTerm ( int N ) { return ( N * ( ( N / 2 ) + ( ( N % 2 ) * 2 ) + N ) ) ; } } class GFG { public static void main ( String [ ] args ) { int N = 5 ; Nth a = new Nth ( ) ; System . out . println ( " Nth ▁ term ▁ for ▁ N ▁ = ▁ " + N + " ▁ : ▁ " + a . nthTerm ( N ) ) ; } }