Check whether a given 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
def check_polydivisible ( n ) : NEW_LINE INDENT N = n NEW_LINE digit = [ ] NEW_LINE while ( n > 0 ) : NEW_LINE INDENT digit . append ( n % 10 ) NEW_LINE n /= 10 NEW_LINE DEDENT digit . reverse ( ) NEW_LINE flag = True NEW_LINE n = digit [ 0 ] NEW_LINE for i in range ( 1 , len ( digit ) , 1 ) : NEW_LINE INDENT n = n * 10 + digit [ i ] NEW_LINE if ( n % ( i + 1 ) != 0 ) : NEW_LINE INDENT flag = False NEW_LINE break NEW_LINE DEDENT DEDENT if ( flag ) : NEW_LINE INDENT print ( N , " is ▁ Polydivisible ▁ number . " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( N , " is ▁ Not ▁ Polydivisible ▁ number . " ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 345654 NEW_LINE check_polydivisible ( n ) NEW_LINE DEDENT