Java Pattern Problems Math