Find the Smallest number that divides X ^ X | Function to find the required smallest number ; Finding smallest number that divides n ; i divides n and return this value immediately ; If n is a prime number then answer should be n , As we can 't take 1 as our answer. ; Driver code
function SmallestDiv ( n ) { for ( let i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { return i ; } } return n ; } let X = 385 ; let ans = SmallestDiv ( X ) ; document . write ( ans + " " ) ;