Error in printing series

import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner s= new Scanner(System.in);
int N1=s.nextInt();
int N2=s.nextInt();
int n=1;
while(n<=N1){
if((3n+2)%N2==0){
System.out.print("");
}
else{
System.out.println(3
n+2);
}
n++;

		    }
}

}

heyy @malikvikram222 You have to print n numbers which are divisible by 3n+2 not till n.
so I have modified your code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n1 = sc.nextInt();
int n2 = sc.nextInt();
int count = 0;
if(n1<=100){
for (int i = 1; count < n1; i++) {
int ap = 3 * i + 2;
if (ap % n2 != 0) {
System.out.println(ap);
count++;
}

        }

      }

}
}
here I have taken n1 <=100 bcoz max value of n1 can be 100

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.