добавь в код проверку вводимых данных
package KnuthDivisionBase10;

import java.util.Arrays;
import java.util.Scanner;

public class KnuthDivisionBase10 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        System.out.println("Введите делимое (u):");
        String uStr = scanner.nextLine().trim();
        System.out.println("Введите делитель (v):");
        String vStr = scanner.nextLine().trim();
        
        int[] u = stringToDigitArray(uStr);
        int[] v = stringToDigitArray(vStr);
        
        if (isZero(v)) {
            System.out.println("Ошибка: деление на ноль!");
            return;
        }
        
        int[][] result = divide(u, v);
        int[] quotient = result[0];
        int[] remainder = result[1];
        
        System.out.println("\nРезультат:");
        System.out.println("Частное: " + digitArrayToString(quotient));
        System.out.println("Остаток: " + digitArrayToString(remainder));
        
        scanner.close();
    }
    
    private static int[] stringToDigitArray(String s) {
        int[] digits = new int[s.length()];
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c < '0' || c > '9') {
                throw new NumberFormatException("Некорректная цифра: " + c);
            }
            digits[i] = c - '0';
        }
        return digits;
    }
    
    private static String digitArrayToString(int[] digits) {
        StringBuilder sb = new StringBuilder();
        for (int digit : digits) {
            sb.append(digit);
        }
        return sb.toString();
    }
    
    private static boolean isZero(int[] number) {
        for (int digit : number) {
            if (digit != 0) return false;
        }
        return true;
    }
    
    public static int[][] divide(int[] u, int[] v) {
        final int base = 10;
        int n = v.length;
        int m = u.length - n;
        
        int d = base / (v[0] + 1);
        int[] uNorm = multiply(u, d);
        int[] vNorm = multiply(v, d);
        
        if (uNorm.length == u.length) {
            uNorm = prependZero(uNorm);
        }
        
        int[] quotient = new int[m + 1];
        
        for (int j = m; j >= 0; j--) {
            int estimatedQ = estimateQ(uNorm, vNorm, j, n, base);
            
            int[] product = multiply(vNorm, estimatedQ);
            int[] sub = new int[n + 1];
            System.arraycopy(uNorm, j, sub, 0, n + 1);
            
            boolean needsAdjustment = subtract(sub, product);
            
            if (needsAdjustment) {
                estimatedQ--;
                add(sub, vNorm);
            }
            
            quotient[j] = estimatedQ;
            System.arraycopy(sub, 0, uNorm, j, sub.length);
        }
        
        int[] remainder = divide(uNorm, d)[0];
        remainder = removeLeadingZeros(remainder);
        quotient = removeLeadingZeros(quotient);
        
        return new int[][]{quotient, remainder};
    }
    
    private static int[] multiply(int[] number, int factor) {
        int[] result = new int[number.length + 1];
        int carry = 0;
        
        for (int i = number.length - 1; i >= 0; i--) {
            int product = number[i] * factor + carry;
            result[i + 1] = product % 10;
            carry = product / 10;
        }
        
        result[0] = carry;
        return removeLeadingZeros(result);
    }
    
    private static boolean subtract(int[] a, int[] b) {
        int borrow = 0;
        
        for (int i = a.length - 1; i >= 0; i--) {
            int diff = a[i] - (i < b.length ? b[i] : 0) - borrow;
            if (diff < 0) {
                diff += 10;
                borrow = 1;
            } else {
                borrow = 0;
            }
            a[i] = diff;
        }
        
        return borrow != 0;
    }
    
    private static void add(int[] a, int[] b) {
        int carry = 0;
        
        for (int i = a.length - 1; i >= 0; i--) {
            int sum = a[i] + (i < b.length ? b[i] : 0) + carry;
            a[i] = sum % 10;
            carry = sum / 10;
        }
    }
    
    private static int estimateQ(int[] u, int[] v, int j, int n, int b) {
        int estimatedQ = (u[j] * b + u[j + 1]) / v[0];
        int estimatedRemainder = (u[j] * b + u[j + 1]) % v[0];
        
        while (estimatedQ >= b || estimatedQ * (v[0] * b + (n > 1 ? v[1] : 0)) > 
              (u[j] * b * b + u[j + 1] * b + (n > 1 ? u[j + 2] : 0))) {
            estimatedQ--;
            estimatedRemainder += v[0];
            if (estimatedRemainder >= b) break;
        }
        
        return estimatedQ;
    }
    
    private static int[] prependZero(int[] number) {
        int[] result = new int[number.length + 1];
        System.arraycopy(number, 0, result, 1, number.length);
        return result;
    }
    
    private static int[] removeLeadingZeros(int[] number) {
        int leadingZeros = 0;
        while (leadingZeros < number.length && number[leadingZeros] == 0) {
            leadingZeros++;
        }
        
        if (leadingZeros == number.length) {
            return new int[]{0};
        }
        
        int[] result = new int[number.length - leadingZeros];
        System.arraycopy(number, leadingZeros, result, 0, result.length);
        return result;
    }
}