Generating numbers that are divisor of their right | Function to check if N is a divisor of its right - rotation ; Function to generate m - digit numbers which are divisor of their right - rotation ; Driver code
< ? php function rightRotationDivisor ( $ N ) { $ lastDigit = $ N % 10 ; $ rightRotation = ( $ lastDigit * pow ( 10 , ( int ) ( log10 ( $ N ) ) ) ) + floor ( $ N / 10 ) ; return ( $ rightRotation % $ N == 0 ) ; } function generateNumbers ( $ m ) { for ( $ i = pow ( 10 , ( $ m - 1 ) ) ; $ i < pow ( 10 , $ m ) ; $ i ++ ) if ( rightRotationDivisor ( $ i ) ) echo $ i . " STRNEWLINE " ; } $ m = 3 ; generateNumbers ( $ m ) ; ? >