Problem · Math
Find Out Prime or Composite
Learn this problemProblem 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[]) → StringExamples
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
- Collect CoinsSeen Jun 2025
- FizzBuzz ProblemSeen May 2025
- Find Largest Sum Contiguous SubarraySeen May 2025
- Find Largest Sum of Continuous SequenceSeen May 2025
- Find Palindrome Sub-stringSeen May 2025
- Count Numbers with Digit SumSeen Mar 2025
- Maximum Chocolates from Jars (L.C. 198 :)Seen Mar 2025
- Find Elements Largest in Row Smallest in ColumnSeen Mar 2025