Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Question3 {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int n ,i,j;
- int count = 0;
- System.out.print("Test Case = ");
- n = input.nextInt();
- for (i=0;i<n;i++)
- {
- int arr[] = new int[n];
- arr[i] = input.nextInt();
- for(j = 2; j< arr[i]; j++)
- {
- if(arr[i] % j == 0)
- {
- count++;
- break;
- }
- }
- if(count == 0)
- {
- System.out.printf("%d is a prime number\n",arr[i]);
- }
- else
- {
- System.out.printf("%d is a not prime number\n",arr[i]);
- }
- count =0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement