Alcuin 's Sequence | Java program for Alcuin 's Sequence ; find the nth term of Alcuin 's sequence ; return the ans ; print first n terms of Alcuin number ; display the number ; Driver code
import java . util . * ; class GFG { static int Alcuin ( int n ) { double _n = n , ans ; ans = Math . round ( ( _n * _n ) / 12 ) - Math . floor ( _n / 4 ) * Math . floor ( ( _n + 2 ) / 4 ) ; return ( int ) ans ; } static void solve ( int n ) { int i = 0 ; for ( i = 1 ; i <= n ; i ++ ) { System . out . print ( Alcuin ( i ) + " , ▁ " ) ; } } public static void main ( String [ ] args ) { int n = 15 ; solve ( n ) ; } }