Program to check Plus Perfect Number | Function to check plus perfect number ; Calculating number of digits ; Calculating plus perfect number ; Checking whether number is plus perfect or not ; Driver Code
function checkplusperfect ( x ) { let temp = x ; let n = 0 ; while ( x != 0 ) { x = parseInt ( x / 10 ) ; n ++ ; } x = temp ; let sum = 0 ; while ( x != 0 ) { sum += Math . pow ( x % 10 , n ) ; x = parseInt ( x / 10 ) ; } return ( sum == temp ) ; } let x = 9474 ; if ( checkplusperfect ( x ) ) document . write ( " " ) ; else document . write ( " " ) ;