Good numbers Java

“Good” numbers

Description

Ivancho considers a number to be “good”, if it can be divided by each of its digits.

For example:

  • 13 is not “good”, because it cannot be divided by 3;
  • 36 is “good”, because it can be divided both by 3 and 6;
  • 102 is “good” - can be divided by 1 and by 2;
  • 103 is not “good” - cannot be divided by 3;

Help Ivancho by writing a program, which counts the “good” numbers between number A and number B (inclusive).

Input

Read from the standard input the numbers A and B received on one line, separated by space.

Output

Print to the standard output the count of “good” numbers.

Constraints

  • 1 <= A <= B <= 100000

Examples

Input

1 10

Output

10

Explanation - between 1 and 10 there are 10 “good” numbers

Input

42 142

Output

29

Input

256 768

Output

50

Хвърля ми “Ivalid return” и “Short circuit”
Any help is welcome :slight_smile:

В началото си импортвал някакви ненужни неща и Main класа ти беше кръстен test,мисля че трябва да е с главни букви по принцип в джава конвенцията.

И инпута ти трябва да чете от 1 ред а не от два,беше объркал метода int a = Integer.parseInt(scanner.next()); а не int a = Integer.parseInt(scanner.nextLine());

След тези промени кода ти работи на 100/100. Браво ,грешките ти бяха само формални.

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int num1 = Integer.parseInt(scanner.next());
        int num2 = Integer.parseInt(scanner.next());
        int output = 0;

        for (int i = num1; i <= num2 ; i++) {
            int currentNum = i;
            String current = i + "";
            int counter = 0;
            while (currentNum != 0) {
                int lastDigit = currentNum % 10;
                if (lastDigit == 0) {
                    counter++;
                    currentNum = currentNum / 10;
                    continue;
                }
                if (i % lastDigit == 0) {
                    counter++;
                }
                currentNum = currentNum / 10;
            }
            if (counter == current.length()) {
                output++;
            }
        }
        System.out.println(output);

    }
}


Много благодаря!