package monu; import java.util.Scanner;
public class Test {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int a = Integer.parseInt(sc.nextLine());
int b = Integer.parseInt(sc.nextLine());
int c=b-a;
if((a > b) || c<0||a <0|| b <= 0){
System.out.println("Provide valid input");
}
else{
int i = 0, num = 0;
String prime = "";
for(i = a;i <= b;i++){
int counter = 0;
num = i;
while(num >= 1){
if(i % num == 0)
counter++;
num--;
}
if(counter == 2)
prime = prime + i + " ";
}
System.out.println(prime);
}
}
}
This is my code there is hidden test should have got check for zero
Aucun commentaire:
Enregistrer un commentaire