Update Problem008.java

Added basic logic