java : jumping caterpillar program
I'm going to assume this question is in the context of quality interview code, not quality production code. Websites like GeeksForGeeks (https://practice.geeksforgeeks.org/problems/jumping-caterpillars/0) 
don't grade you based on production code quality.

Your failure to correctly spell the most important word in the problem domain (Caterpillar) would put me off to a sour start. To me, that suggests an inattention to detail. In software development, little details can make a big difference.

You're doing a lot more work than you need to. The basic algorithm here should be - for each leaf, if it can be evenly divided by any of the caterpillar numbers, it gets eaten and you should move on. If none of the caterpillars eat it, increment the uneaten count and continue.

In idiomatic Java, 
whitespace is placed between a control flow keyword (if, else) and the open paren
there is no whitespace before a semicolon
binary operators, including -, == and -, should have whitespace on both sides.
opening curly braces belong on the same line, not a newline

You should use try-with-resources blocks to handle closeable resources such as Scanner.

testcase is not a good variable name because it doesn't correctly explain what it's pointing to. numberOfTestCases would be better. scanner is also better than sc, because I don't have to assume what it holds.

You can also look for more opportunities to break out methods. A method with as much nested code as you have is hard to read and understand. Maximize readability until you have a known performance bottleneck.

If you were to rewrite your code using all these suggestions, it might look more like the untested code below:

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

public class Caterpillar {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int numberOfTestCases = sc.nextInt();

            for (int testCase = 0; testCase &lt; numberOfTestCases; testCase++) {
                int numberOfLeaves = sc.nextInt();
                int[] caterpillars = readCaterpillarsFrom(sc);
                int uneatenLeaves = 0;
                for (int leaf = 1; leaf &lt;= numberOfLeaves; leaf++) {
                    if (isLeafUneaten(leaf, caterpillars)) {
                        uneatenLeaves++;
                    }
                }
                System.out.println(uneatenLeaves);
            }
        }
    }

    private static int[] readCaterpillarsFrom(Scanner scanner) {
        int[] caterpillars = new int[scanner.nextInt()];
        for (int j = 0; j &lt; caterpillars.length; j++) {
            caterpillars[j] = scanner.nextInt();
        }

        /* You're more likely to get a hit on smaller numbers, so the sort helps you leave earlier in some cases.
         * This is arguably a premature optimization, and may be a performance loss if the there are many 
         * caterpillars and few leaves.
         */
        Arrays.sort(caterpillars);

        return caterpillars;
    }

    private static boolean isLeafUneaten(int leaf, int[] caterpillars) {
        for (int caterpillar : caterpillars) {
            if (leaf % caterpillar == 0) {
                return false;
            }
        }
        return true;
    }

}