text: Program to print the series 1 , 3 , 4 , 8 , 15 , 27 , 50 â €¦ till N terms | Java implementation to print the N terms of the series whose three terms are given ; Function to print the series ; Generate the ith term and print it ; Driver Code ; Function Call
code: import java . util . * ; class GFG { static void printSeries ( int n , int a , int b , int c ) { int d ; if ( n == 1 ) { System . out . print ( a + " ▁ " ) ; return ; } if ( n == 2 ) { System . out . print ( a + " ▁ " + b + " ▁ " ) ; return ; } System . out . print ( a + " ▁ " + b + " ▁ " + c + " ▁ " ) ; for ( int i = 4 ; i <= n ; i ++ ) { d = a + b + c ; System . out . print ( d + " ▁ " ) ; a = b ; b = c ; c = d ; } } public static void main ( String [ ] args ) { int N = 7 , a = 1 , b = 3 ; int c = 4 ; printSeries ( N , a , b , c ) ; } }