Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class PrimeAgain {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int soTest = input.nextInt();
- int[] nhap = new int[soTest];
- int[] xuat = new int[soTest];
- for(int l = 0 ; l <= soTest - 1 ; l ++) {
- nhap[l] = input.nextInt();
- for(int i = 0 ; i <= nhap[l] ; i++ ) {
- int root = (int) Math.sqrt(i);
- for(int j = 2; j <= root ; j++ ) {
- if ( (i % j) == 0 ) break;
- if ( j == root ) xuat[l] = i;
- }
- }
- }
- for(int n = 0 ; n <= soTest - 1 ; n++ ) {
- System.out.println(xuat[n]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment