Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class GoodNumbes {
- public static int checkDigits(int a, int b){
- boolean isGood = true;
- int counterNum = 0;
- for (int i = b; i >= a; i--) {
- if (a <= 10 && b <= 10) {
- counterNum++;
- } else {
- isGood = true;
- int counter = 0;
- int[] arr = new int[10];
- int copy = i;
- while (copy > 0) {
- int digit = copy % 10;
- arr[counter] = digit;
- counter++;
- if (!(copy > 10)) {
- break;
- }
- else{
- copy /= 10;
- }
- }
- for (int j = 0; j < counter; j++) {
- if (arr[j] == 0) {
- continue;
- }
- if (i % arr[j] != 0) {
- isGood = false;
- break;
- }
- }
- if (isGood) {
- counterNum++;
- }
- isGood = true;
- }
- }
- System.out.println();
- return (counterNum);
- }
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- String line = in.nextLine();
- String[] nums = line.split(" ");
- int[] arr = new int[2];
- for (int i = 0; i < arr.length ; i++) {
- arr[i] =Integer.parseInt(nums[i]);
- }
- int a = arr[0];
- int b = arr[1];
- System.out.println(checkDigits(a, b));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement