read X
for i in {2..33}; do
        for j in {2..10}; do
                result=$((i**j))
                [ "$result" -le "$X" ] && echo $result || break
        done
done | sort -nr | cat - <(echo 1) | head -1