Function to find the longest subsequence which contain all powerful numbers
function longestPowerfulSubsequence ( arr , n ) { let answer = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( isPowerful ( arr [ i ] ) ) answer ++ ; } return answer ; }