Find a range of composite numbers of given length | Java program to find a range of composite numbers of given length ; method to find factorial of given number ; to print range of length n having all composite integers ; Driver method
class Test { static int factorial ( int n ) { if ( n == 0 ) return 1 ; return n * factorial ( n - 1 ) ; } static void printRange ( int n ) { int a = factorial ( n + 2 ) + 2 ; int b = a + n - 1 ; System . out . println ( " [ " + a + " , ▁ " + b + " ] " ) ; } public static void main ( String args [ ] ) throws Exception { int n = 3 ; printRange ( n ) ; } }