Number obtained by reducing sum of digits of 2 N into a single digit | Function to find the number obtained by reducing sum of digits of 2 ^ N into a single digit ; Stores answers for different values of N ; Driver Code
function findNumber ( N ) { let ans = [ 1 , 2 , 4 , 8 , 7 , 5 ] ; return ans [ N % 6 ] ; } let N = 6 ; document . write ( findNumber ( N ) + " " ) ;