Program to find all Factors of a Number using recursion | Recursive function to print factors of a number ; Checking if the number is less than N ; Calling the function recursively for the next number ; Driver code
function factors ( n , i ) { if ( i <= n ) { if ( n % i == 0 ) { document . write ( i + " " ) ; } factors ( n , i + 1 ) ; } } var N = 16 ; factors ( N , 1 ) ;