Problem · Math

Find Out Prime or Composite

Learn this problem
EasyCiscoINTERNOA
See Cisco hiring insights

Problem statement

Given a list of integers, write an algorithm to find out if the elements are prime or composite.

Input

The first line of input consists of an integer inputList-size, representing the number of elements in the list (N). The next line consists of N space-separated integers representing the elements of the list.

Output

Print N line-separated "Prime" if the element is a prime number else print "Composite" if the element is a non-prime number.

Note

Prime numbers are those positive integers that have no positive integer divisors other than 1 and itself.

Function

findOutPrimeOrComposite(size: int, elements: int[]) → String

Examples

Example 1

size = 5elements = [541, 37, 113, 5, 10]return = "Prime Prime Prime Prime Composite"

From the given list, elements (541, 37, 113, 5) are prime numbers and (10) is a composite number.

More Cisco problems

drafts saved locally
public String findOutPrimeOrComposite(int size, int[] elements) {
  // Write your code here
      
}
size5
elements[541, 37, 113, 5, 10]
expected"Prime Prime Prime Prime Composite"
checking account