Fixed formatting and moved input sanitation outside of the thread that does the factoring. The private inner class that does the factoring now implements the Runnable interface instead of extending Thread.