Created
January 26, 2023 14:03
-
-
Save mosishon/d16ecb4e60d34567c40bcdbb5376eddf to your computer and use it in GitHub Desktop.
تمرین شماره 649 کوئرا . (سیستم کشف تقلب کوئرا رو یادتون نره)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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