text: Iterate through all divisors and check for N mod d = 1 or ( N - 1 ) mod d = 0
code: div . forEach ( d => { var K = N ; while ( K % d == 0 ) K /= d ; if ( ( K - 1 ) % d == 0 ) answer ++ ; } ) ; return answer ; }