Find all divisors of first N natural numbers | C # implementation to find all the divisors of the first N natural numbers ; Function to find the factors of the numbers from 1 to N ; Loop to find the factors of the first N natural numbers of the integer ; Driver Code
using System ; class GFG { static void factors ( int n ) { int i , j ; Console . Write ( "1 ▁ - - > 1 STRNEWLINE " ) ; for ( i = 2 ; i <= n ; i ++ ) { Console . Write ( i + " ▁ - - > " ) ; for ( j = 1 ; j * j <= i ; j ++ ) { if ( i % j == 0 ) { Console . Write ( j + " , ▁ " ) ; if ( i / j != j ) Console . Write ( i / j + " , ▁ " ) ; } } Console . Write ( " STRNEWLINE " ) ; } } public static void Main ( ) { int n = 5 ; factors ( n ) ; } }