Skip to content

Instantly share code, notes, and snippets.

@mosishon
Created January 26, 2023 14:03
Show Gist options
  • Save mosishon/d16ecb4e60d34567c40bcdbb5376eddf to your computer and use it in GitHub Desktop.
Save mosishon/d16ecb4e60d34567c40bcdbb5376eddf to your computer and use it in GitHub Desktop.
تمرین شماره 649 کوئرا .‌ (سیستم کشف تقلب کوئرا رو یادتون نره)
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
int counter = 1;
for(int i=a+1;i<b;i++){
if(isPrime(i)) {
if (counter !=1) {
System.out.print(",");
}
counter+=1;
System.out.print(i);
}
}
}
public static boolean isPrime(int n){
for(int i=2;i<=n/2;i++){
if(n%i == 0){
return false;
}
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment