Check whether a given number is Polydivisible or Not | C # program to check whether a number is polydivisible or not ; function to check polydivisible number ; digit extraction of input number ; store the digits in an array ; n contains first i digits ; n should be divisible by i ; Driver code
using System ; using System . Collections . Generic ; class GFG { static void check_polydivisible ( int n ) { int N = n ; List < int > digit = new List < int > ( ) ; while ( n > 0 ) { digit . Add ( ( int ) n % 10 ) ; n /= 10 ; } digit . Reverse ( ) ; bool flag = true ; n = digit [ 0 ] ; for ( int i = 1 ; i < digit . Count ; i ++ ) { n = n * 10 + digit [ i ] ; if ( n % ( i + 1 ) != 0 ) { flag = false ; break ; } } if ( flag ) Console . WriteLine ( N + " ▁ is ▁ Polydivisible ▁ number . " ) ; else Console . WriteLine ( N + " ▁ is ▁ Not ▁ Polydivisible ▁ number . " ) ; } public static void Main ( String [ ] args ) { int n = 345654 ; check_polydivisible ( n ) ; } }