Deserium Number | Returns count of digits in n . ; Returns true if x is Diserium ; Compute powers of digits from right to left . ; If sum of powers is same as given number . ; Driver Code
< ? php function countDigits ( $ n ) { $ c = 0 ; do { $ c ++ ; $ n = $ n / 10 ; } while ( $ n != 0 ) ; return $ c ; } function isDeserium ( $ x ) { $ temp = $ x ; $ p = countDigits ( $ x ) ; $ sum = 0 ; while ( $ x != 0 ) { $ digit = $ x % 10 ; $ sum += pow ( $ digit , $ p ) ; $ p -- ; $ x = $ x / 10 ; } return ( $ sum == $ temp ) ; } $ x = 135 ; if ( isDeserium ( $ x ) ) echo " No " ; else echo " Yes " ; ? >